sommcewce
sommcewce

Reputation: 73

The maximum file size uploaded using PHP and html5?

Any idea on how big the file size could one file uploaded using php and html5?

And

Is there any suggestions on good components or example to do this?

thanks a lot!

Upvotes: 0

Views: 4008

Answers (3)

Michel Feldheim
Michel Feldheim

Reputation: 18250

On the server side the maximum upload size is limited by php post_max_size and upload_max_filezize.

Also your webserver can limit the maximum size of your post body. E.g. Apache limitrequestbody which defaults to 0 = unlimited or nginx client_max_body_size which defaults to 2MB

If you are planning to upload large files using html5 you might want to have a look at file.slice which is supported by all modern browsers

Support for .slice in the File API Firefox supports the Blob API and the .slice APIs that come with it. This can help people who want to process parts of large File objects from JavaScript without having to load the whole file into the memory. People who reliably upload large files can use some server and JS code to split a large file into sections and upload chunks, including re-retrying failed sections, or even uploading several sections, in parallel.

Using this, you could upload giant files in chunks and merge them on the server-side again.

EDIT

Found this great article which explains html5 uploads by streaming via xhr

http://www.webiny.com/blog/2012/05/07/webiny-file-upload-with-html5-and-ajax-using-php-streams/

This procedure has a very low memory footprint, you might still run into the webserver and php upload limits because this is done with a single request. The code should give you an idea on how the whole technology works.

Upvotes: 2

Vijay jain
Vijay jain

Reputation: 14

The maximum file size value is defined in phi.ini file.

search this in php.ini

Maximum allowed size for uploaded files.

upload_max_filesize = 32M

Upvotes: 0

One Man Crew
One Man Crew

Reputation: 9578

PHP's pretty crappy when it comes to large file uploads, particularly because you have to a memory limit higher than the size of the file. As well, Apache on 32bit systems tends to have a 2gig file limit itself, so even if PHP could handle the upload, Apache will choke.

You need to set the value of upload_max_filesize and post_max_size in your php.ini :

; Maximum allowed size for uploaded files. upload_max_filesize = 40M

; Must be greater than or equal to upload_max_filesize post_max_size = 40M

If you can't change your php.ini, you're out of luck. You cannot change these values at run-time; uploads of file larger than the value specified in php.ini will have failed by the time execution reaches your call to ini_set.

See the Description of core php.ini directives.

The maximum size of an uploaded file is integer. When an integer is used, the value is measured in bytes

Upvotes: 2

Related Questions