Forum Moderators: phranque

Message Too Old, No Replies

Upload File using apache disappears from /tmp

PHP recognises upload success but is not in /tmp

         

perplexedagain

8:29 pm on Aug 18, 2005 (gmt 0)

10+ Year Member



Hi, i'm trying in vain to upload a file using the html form...

// HTML
<form name='form' method='post' action='<!--{ $WWW }-->user/' enctype="multipart/form-data" />
<input type='text' name='sss' value='ss'>
<label for'pic'>Upload an image</label> <input type='file' name='pic'/>
<input type='submit' value='Insert image' />
</form>

I grab this and have printed out the variables

// PHP
print_r($_FILES);


Array
(
[pic] => Array
(
[name] => whatahandsomefellowiam.jpg
[type] => image/jpeg
[tmp_name] => /tmp/phpGyP2AB
[error] => 0
[size] => 28590
)

)

So from this i gather that my file has been uploaded to the temp file /tmp/phpGyP2AB. But it hasn't! My inital attempts to copy the file using php failed investigation led to discovery that it hadn't been put there.

I checked potential reasons...
/tmp file write permissions, yup chmod 1777 /tmp

Configuration php.ini...

; Whether to allow HTTP file uploads.
file_uploads = On

; Temporary directory for HTTP uploaded files (will use system default if not
; specified).
upload_tmp_dir = /tmp

; Maximum allowed size for uploaded files.
upload_max_filesize = 2M

Firewall blocking, i turned firewalls off /etc/init.d/iptables stop

SELinux, i checked less /etc/sysconfig/selinux


SELINUX=Disabled
SELINUXTYPE=targeted

I'm completely dumbfounded. What configuration have i missed? I'm using an out of the box LAMP settup, fedora 4 distribution.

Thanks in advance for feedback

ChadSEO

10:41 pm on Aug 18, 2005 (gmt 0)

10+ Year Member



perplexedagain,

I'm not sure when you're are checking for the existance of the file, but a note from the documentation:

The file will be deleted from the temporary directory at the end of the request if it has not been moved away or renamed.

An easy to see if the file is being uploaded is just to copy it to a new location, like this:

copy($_FILES['pic']['tmp_name'],"/tmp/" . $_FILES['pic']['name']);

This should place a copy of the file in the /tmp directory with the same filename as the original.

Chad

perplexedagain

1:07 pm on Aug 19, 2005 (gmt 0)

10+ Year Member



Thanks Chad, thats it! The file i was trying to copy it too was write protected.

Drew.
I feel this ->. big right now.