Re: Image upload form

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thursday 16 June 2005 00:38, Jack Jackson wrote:

> //try to get image size; this returns false if this is not an actual
> image file.
>        $image_test = getimagesize($local_file);
> 	if ($image_test !== false) {
> 	   $mime_type = $_FILES['userfile']['type'];

$_FILES['userfile']['type'] contains the mime-type that is provided by the 
browser and will vary depending on browser and hence extremely 
unreliable.

In fact the returned value from getimagesize() already has mime-type info, 
use that instead.

>   $newfile = md5(date("l-F-j-Y i:s")).'.'.$pext;
>
>   $image_file = $uploaddir . $newfile;
>
> // print_r($newfile);
> // print_r($image_file);
>
>   if(!move_uploaded_file($newfile,$image_file)) {
>
> 	 echo 'Could not move file to destination';
> 	 exit;
>   }

The file pointed to by $newfile doesn't exist. You need to move ...

>       $local_file = $_FILES['userfile']['tmp_name'];

... $localfile


-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
New Year Resolution: Ignore top posted posts

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux