0

I have a php upload script wich cycles through 18 files which it should upload average size about 8 MB, but the website isn't uploading all the files, however if I try it with 2 or 3 it works fine, so is there a limit for security reasons or something?

EDIT: Thank You for all your answers, there is more than one answer that is correct, so unfortunately I can't mark all of them correct but thank you for the attempt :)

2
  • 1
    It's probably a cache thing, not a PHP limit. Commented Jun 8, 2011 at 20:58
  • hmmmmm, do you know a workaround? Commented Jun 8, 2011 at 20:59

3 Answers 3

3

in php.ini change

upload_max_filesize = 100M or your number

memory_limit = 128M or your number

and

post_max_size = 100M
Sign up to request clarification or add additional context in comments.

1 Comment

Other options to consider: max_file_uploads (factory default is 20, but this varies so worth to check.)
2

Are you getting any errors? If you aren't seeing them, check your php error log.

Try increasing the PHP's memory limit,

ini_set('memory_limit', '128mb');

And try increasing the time limit on your script,

set_time_limit(0); //infinite

4 Comments

ini_set() makes no sense for uploads. It get's into action too late. Set those values in your php.ini file instead.
@hakre Why would you assume that? If the files are stored in memory to be processed during the upload, surely this is important..
@hakre On second thought, how is this any different from php.ini or at runtime. They are identical. You are probably thinking about the maximum upload filesize, which yes, should be set in php.ini.
The POSTDATA of the request is loaded into php memory. If this triggers the memorylimit, then php will exit. The ini_set() command has not yet been executed. So if the memory limit set in php.ini is too low, you can not make a difference with ini_set for file uploads.
1

@John I think this not related to memory, instead, its related file size upload limit by php.ini, so try to chnage this in php.ini:

upload_max_filesize = 170M // 8 * 18 ~ 160

If you can't access to php.ini, you can try to add this line to .htaccess file in your root directory:

php_value upload_max_filesize 170M

Note: Your script may file if some file is bigger then your memory limit. So keep in your mind that memory used to store file during upload progress.

3 Comments

If it was related to the maximum upload filesize, the entire $_FILES array would be empty. This is not the case as the OP stated some of the files were uploaded.
@John Once, I had uploaded dumped database, it was big, the size of it is less then my memory limit but it was greater then upload size limit, changing the upload size limit fix my problem.
Please revisit my comment. If the sum of all the file-sizes exceed the maximum file-size defined by php.ini, the ENTIRE $_FILES array will be empty. In this case, since some files were uploaded, it indicates the maximum size was not exceeded, but either it ran out of memory processing the uploads, or ran out of time to process them.

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.