Re: problem finding out original filename while using php to upload.

From: Date: Mon, 17 Dec 2001 04:38:58 +0000
Subject: Re: problem finding out original filename while using php to upload.
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-77899@lists.php.net to get a copy of this message
Well..to determine the format the file file..you may find some sort of routine to check..but why not create one? I mean, in windows, the extension determines the file format right? So do a loop that starts from the last character, and goes back one until you reach the "." (dot). Based on that you can determine the format type.. Of course, if the user renamed a .bmp to a .jpeg then you won't be able to tell that this was originally a .bmp file... Ray Gaylog rgaylog@rogers.com ----- Original Message ----- From: "Neil M" <neil@web100.co.uk> To: <php-general@lists.php.net> Sent: Sunday, December 16, 2001 3:22 PM Subject: [PHP] problem finding out original filename while using php to upload. > 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 > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#77899) next »