Forum Moderators: phranque
// 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>
// 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
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