RE: problem finding out original filename while using php to uplo ad.
| From: | UGBI) | Date: | Mon, 17 Dec 2001 10:24:12 +0000 |
| Subject: | RE: problem finding out original filename while using php to uplo ad. | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-77925@lists.php.net to get a copy of this message | ||
You could also use the function getimagesize this will tell what kind of
image it is, and if it is not an image it will return false.
GD LIB is NOT needed for getimagesize.
Kind Regards,
Jerry Verhoef
-----Original Message-----
From: Daniel Grace [mailto:rubein@earthlink.net]
Sent: Monday, December 17, 2001 6:52 AM
To: php-general@lists.php.net
Subject: Re: problem finding out original filename while using php to
upload.
"Neil M" <neil@web100.co.uk> wrote in message
news:20011216203002.56303.qmail@pb1.pair.com...
> I am using php to upload image files.
>
> heres my code ..
>
> <?
> if (is_uploaded_file($photo_file))
> {
>
> clearstatcache ();
> $size = filesize ( $photo_file ) ;
> if ( $size > 1024000 )
> {
> print ("<BR> ERROR - File is too big ! File uploads should be below 1024
k
> ( 1mb ) <BR>"); exit ;
> }
> move_uploaded_file($photo_file, "$upload_path$check_nick->nickname");
> }
> else
> {
> echo "<BR> ERROR : File upload was not successfull , please try again
> !<BR>";
> }
> ?>
>
> ------
>
> the problem is that when i look for the original filename ( e.g.
> myphoto.gif ) , $photo_file contains a random file name like 383hr93php
>
> As i mentioned , its image files i am uploading , how do i know what type
of
> image the file was ? like .jpg , .png etc.
>
> Any help appreciatted , i am really stuck on this ;0)
>
> Thanks
>
> Neil M
>
$photo_file will map to the name of the temporary file on the server's HD --
it is NOT the name of the original file. You'll want to use $photo_file_name
to determine the original filename, or better yet, $photo_file_type to
determine the content type. (a gif is image/gif, for instance).
See http://www.php.net/manual/en/features.file-upload.php
--
Daniel Grace
echo make_witty_sig($foo) . "\n";
The information contained in this email is confidential and
may be legally privileged. It is intended solely for the
addressee. Access to this email by anyone else is
unauthorized. If you are not the intended recipient, any
form of disclosure, production, distribution or any action
taken or refrained from in reliance on it, is prohibited and
may be unlawful. Please notify the sender immediately.
The content of the email is not legally binding unless
confirmed by letter bearing two authorized signatures.