Large File uploading options using PHP
I have always had issues with Large file uploading with PHP.
I heard that Perl is an alternative and a reliable way of handling large file uploads.
or Is there a better way in php (using swfupload etc) 开发者_高级运维to manage large file uploads.
Do you have any idea about this?
Thanks, B2W 2011
There are 3 configuration options that affects file uploading in php, all of them in php.ini, and some of them configurable at runtime.
You should take care of:
**max_input_time** its the time a script could invest in parsing the input
**file_uploads should** be set to on, it determines if uploads are allowed at all or not
**upload_max_filesize** is the maximum size for the uploaded files
**post_max_size** since uploads are inside POST requests, you should raise this value at least to the value you specified in upload_max_filesize
After you change this settings in php.ini, remember to restart apache.
It is also adviced to remove the max execution time limitation with:
set_time_limit(0); at code level.
Aside from that, remember that if you upload large files, you should never put the content of the files directly inside a variable, you would run out of memory if you do it.
Normally when you disable the timeout limit using set_time_limit(0)
it should not produce any errors.
How large? I believe that if the file is too (hundreds of megabytes), perhaps use a service dedicated to this (S3/DropBox, etc)?
Perl is an interpreted server-side language that runs on top of the web server, just like PHP, you switching languages is unlikely to change anything.
Is there a better way? Since you don't say you what issues are, we can't suggest a way to fix them ;-)
精彩评论