Re: Image upload

From: Date: Mon, 05 Feb 2007 23:25:04 +0000
Subject: Re: Image upload
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-248395@lists.php.net to get a copy of this message
Jochem Maas wrote:
Robert Fitzpatrick wrote:
I have a small application that ran on one server and now gives me a problem with uploading images on a new server. I am running PHP 4.4.4 now on this server and hoping it is just something that needs adjusted in php.ini, but cannot seem to find. The file is posted as a file fields in a multipart/form-data form, the application tests the file with getimagesize() shown below. I am getting the die response in the browser. I tried echo of the file and it prints a random file name under the /tmp directory on this CentOS Linux system. If I sleep for 10 seconds, the file gets created and gone after the script finishes. Can someone suggest what my problem may be?
    
no. but start by stopping the assumption that getimagesize() returns something equivelant to false to mean the same thing as that the file does not exist (or is not an image file.) this might help: http://php.net/is_uploaded_file Yes, actually that is done first, the getimagesize is used it the script to test it as an image. This was written by someone else and worked prior to moving servers. This is a more complete snippet of the code:
if (is_uploaded_file($_FILES['filPhoto']['tmp_name'])) {
      // use getimagesize to make sure it's an image file
     if (!getimagesize($_FILES['filPhoto']['tmp_name'])) {
           die('The file you are attempting to upload is not an image file.');
<snip>
also check it's not a permissions issue (i.e. the file is being created but the webserver cannot subsequently read the file) The /tmp directory where it is created is set with 777 perms. I have not checked the destination, but the script does not appear to get back the above point, giving us the die response.
-- Robert

« previous php.general (#248395) next »