I had uploaded two PDF files to the server in php. but they are uploaded correctly but when uploading larger files I get an error. Iam using mysql server
How to upload large files(100 mb) in php?
I had uploaded two PDF files to the server in php. but they are uploaded correctly but when uploading larger files I get an error. Iam using mysql server
How to upload large files(100 mb) in php?
From the php.ini default settings:
; Maximum allowed size for uploaded files.
; http://php.net/upload-max-filesize
upload_max_filesize = 2M
Change this value if you want larger uploads.
I am not entirely sure, but I do not think that ini_set would work in this situation. You will need direct access to php.ini
I would not change the upload_max_filesize. Uploading large files with HTTP POST doesn't give you any feedback as to how much time is left to upload, etc. For most browsers, the page just hangs there while the file uploads. You also run into script timeout issues if it takes too long for the client to upload the file. Depending on if you process the file in PHP afterwards, you can also run into memory exhausted issues.
We use PLUpload http://www.plupload.com which chunks the file into smaller pieces and uploads each chunk. On the server, a PHP script will take each POST file chunk and append it to the existing chunks to rebuild the large file on the other side. We have tested with files going into a few hundred MB's. This works better and is a much nicer user experience for users.
Leo
To add to Tom van der Woerdt's answer about upload_max_filesize:
Chances are, default execution limits will also have to be changed, or the script will timeout while you're uploading a large file.
Also look into:
post_max_size
max_input_time
max_execution_time
You may need to change the following options in php.ini file:
upload_max_filesize (in php.ini or .htaccess only, won't work using ini_set())
post_max_size (ditto)
memory_limit (ditto)
Here is the explanation for each option:
There are 3 settings PHP uses that limit your uploading ability:
post_max_size
This is the combined maximum size of all files sent on the form. If you have 2 file fields on your form, the total filesize of the 2 files must not exceed the post_max_size value.
upload_max_filesize
This is the filesize limit of each individual file.
memory_limit
PHP scripts have a memory limit, and generally speaking this can prevent some uploads from working. The limit should be set at a reasonable level, of course you won’t need 20mb for a simple ‘hello world’ script. Try slowly increasing this value if you find that uploads still aren’t working.
The suggestion to set max_upload_size and post_max_size is correct, but you may still encounter problems in some installations. One thing to remember when setting these values is that post_max_size is at least double the value of max_upload_size. In other words, if you set max_upload_size to 100mb, then post_max_size must be 200mb, otherwise the settings will be rejected and the engine will use the default settings of 2mb and 8mb instead. Also, you need to be sure that memory_limit is at least the size of max_upload_size. If you crank up the post and upload sizes, but you are not allotting enough memory then you will still run into problems.