4

I'm trying to debug a very strange problem with the $_FILES array. When I try to upload a file, only the 'name' key is set, the type, tmp_name, etc. are empty, and it's returning error #1. For example:

Array
(
    [name] => test.doc
    [type] => 
    [tmp_name] => 
    [error] => 1
    [size] => 0
)

test.doc is a valid file, I can open it without a problem. This is happening to a bunch of files I tested; doc, pdf, xls, ppt, jpg. The only file types that works are txt and gif.

I'm getting this problem on both on CentOS 5.3 w/PHP 5.2.6, Apache 2.2.3 and Ubuntu 8.04 w/PHP 5.2.4, Apache 2.2.8.

I thought I may have been mime types, but I checked the mime types and all the common ones are available.

Any ideas? I've never had this problem before!

Thanks.

2 Answers 2

7

The error code of 1 means the file exceeds the maximum upload size set in php.ini.

All the various errors messages are explained here: http://php.net/manual/en/features.file-upload.errors.php

Sign up to request clarification or add additional context in comments.

Comments

5

According to the PHP documentation on file uploads, an error value of 1 (AKA UPLOAD_ERR_INI_SIZE) means:

The uploaded file exceeds the upload_max_filesize directive in php.ini.

You can try adjusting the upload-max-filesize setting.

EDIT: The correct syntax for specifying upload_max_filesize in megabytes is 25M, not 25MB. See the documentation on using shorthand for details.

8 Comments

Sorry, I didn't mention that the files I'm trying to upload are very small <100KB. I have upload_max_filesize set to 25MB and post_max_size to 100MB
Actually, looks like the daily vote cap is 30, not 35 like I initially stated. See here: meta.stackexchange.com/questions/5212/…
@Daniel: Perhaps the values in your php.ini are being overridden by either your Apache vhost config or at runtime. What is the output of echo "upload_max_filesize = " . ini_get('upload_max_filesize'); when executed in your file upload handling script?
@Daniel: The syntax of "25MB" looks slightly wrong. Try changing it to "25M" in php.ini. See the following link for shorthand syntax: php.net/manual/en/faq.using.php#faq.using.shorthandbytes
@Asaph, Oh man, that did it! I was totally blinded by it, post_max_size was properly set to 100M, but the value for upload_max_filesize was 25MB. Thanks so much!
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.