Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to stop a oversize file upload while upload is in process?

I'm using apache, PHP.

So, for php, even I set max file size, if someone upload a huge file, it will upload the whole thing to server, and then PHP return error. is that right?

I would like the web server or PHP to stop when the file size or the request size is larger than certain size.

is there a way to do it? I remember something like setting post_max_size or setting something in apache.conf but not sure if it will stop when the file goes over the max limit.

  • I don't trust client side validation. so, I'm looking for either apache or php level solution. :)
like image 550
murvinlai Avatar asked Jan 27 '12 22:01

murvinlai


People also ask

How do I handle a large upload?

Possible solutions: 1) Configure maximum upload file size and memory limits for your server. 2) Upload large files in chunks. 3) Apply resumable file uploads. Chunking is the most commonly used method to avoid errors and increase speed.

How do I change the file upload size?

Open the file in any text editor and add the following code. @ini_set( 'upload_max_size' , '20M' ); @ini_set( 'post_max_size', '13M'); @ini_set( 'memory_limit', '15M' ); Save your changes, and it should increase your file upload size.

What is the maximum file size for file uploading?

The maximum file size limit for uploads to Box varies depending on your account type: Free personal: 250 MB. Starter: 2 GB. Business: 5 GB.


1 Answers

Apache's LimitRequestBody, afaik, it just stops the connection when going over....

like image 181
Wrikken Avatar answered Nov 09 '22 20:11

Wrikken