Search code examples
phpuploading

uploading docx in php works half the time


I'm making a simple document management system. It is implemented on two different servers. One has a weird bug and the other doesn't. While uploading a file (same file in all cases mentioned below)

On the buggy server:

print_r($sUploadFile);
die();

yields:

Array ( [name] => Human Resources.docx [type] => [tmp_name] => [error] => 1 [size] => 0 ) 

which isn't too useful. I cant figure out why error is set. On the not buggy server it yields:

Array ( [name] => Human Resources.docx [type] => application/vnd.openxmlformats-officedocument.wordprocessingml.document [tmp_name] => /tmp/phploctg0 [error] => 0 [size] => 2211177 )

In both cases sUploadFile comes from an html form and in both cases I'm grabbing a working docx file from my desktop.

Any ideas why the file array works on one server and not the other? Ideally this solution should be platform indepent.


Solution

  • This specific file upload error code means that the file is larger than the server's upload_max_filesize limit.