Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

PHP 

PHP File uploader can't handle big files

So I was learning PHP the other day and figured I'd make a file uploader for my website.
It works very well with small files but as soon as I try to upload big files I see this progress thingy in my browser:
[Image: lEtGGD1.png]

As soon as it finishes I should get a page with a link like this:
[Image: zMUWGLm.png]

But it just redirects me to the upload page.

Code
https://pastebin.com/xaSMqDLR

Also, I sometimes just get the "error" 'file can not be bigger than 1000mb (was '. $_FILES['file']['size'] . ')' on my page when I upload a gif. No idea why that happens.
I mean, did you even attempt to Google the question before creating the thread? I just googled "PHP upload files larger than 100mb" and found answers.
(Feb 6, 2019 04:59 AM)+Haze Wrote:  I mean, did you even attempt to Google the question before creating the thread? I just googled "PHP upload files larger than 100mb" and found answers

The file I tried to upload wasn't bigger then 100mb though.
(Feb 6, 2019 05:01 AM)Lynx Wrote:  The file I tried to upload wasn't bigger then 100mb though.

My bad, I apologise.

Well, that does sound very strange. Do you have a direct link to your website I can take a look at?
(Feb 6, 2019 05:06 AM)+Haze Wrote:  My bad, I apologise.

Well, that does sound very strange. Do you have a direct link to your website I can take a look at?

Oh. I changed those values in the php.ini file and it is working, i guess. But the other problem is this error:
PHP Code

<?php 
file can not be bigger than 1000mb 
(was 0) 
very strange
(Feb 6, 2019 05:07 AM)Lynx Wrote:  Oh. I changed those values in the php.ini file and it is working, i guess. But the other problem is this error:
PHP Code

<?php 
file can not be bigger than 1000mb 
(was 0) 
very strange

Yeah that's the solution I found when I Googled the problem too.

To answer your second question
https://pastebin.com/xaSMqDLR

Code
if(!$_FILES['file']['size'] < 1000000000){

Remove the not operator (!)

so it should be

Code
if($_FILES['file']['size'] < 1000000000){
(Feb 6, 2019 05:10 AM)+Haze Wrote:  Yeah that's the solution I found when I Googled the problem too.

To answer your second question
https://pastebin.com/xaSMqDLR

Code
           if(!$_FILES['file']['size'] < 1000000000){

Remove the not operator (!)

so it should be

Code
           if($_FILES['file']['size'] < 1000000000){

Aha thank you. Thats the other problem solved. Now I got the same issue again.
[Wed Feb 6 15:58:22 2019] PHP Warning: POST Content-Length of 77313218 bytes exceeds the limit of 8388608 bytes in Unknown on line 0
That is the error code I get. I am pretty sure I changed the php.ini file though.

I will figure this one out myself, thanks for the help though!
^ That error is saying that you're trying to post a HTTP request with the content length of 77MB, meanwhile the limit is 8MB.

You should check your web requests and see what they look like.
Are you sending the request properly?
Using correct headers?
Correct encoding type?
(Feb 6, 2019 10:10 AM)+Haze Wrote:  ^ That error is saying that you're trying to post a HTTP request with the content length of 77MB, meanwhile the limit is 8MB.

You should check your web requests and see what they look like.
Are you sending the request properly?
Using correct headers?
Correct encoding type?

Yes I know what the error meant but I forgot to restart the server. At least... the correct server haha.
All working fine now. Thank you for the help 🤝
Just as a head's up, you may need to increase your max_input_time directive. By default, per the documentation, it'll use whatever your max_execution_time setting is. I wouldn't advise changing that though. The max_input_time directive is specifically for parsing input data- such as the file(s) being uploaded.

Also, and I'm assuming you fixed this if you're no longer having issues, be mindful of post_max_size. Per the documentation, make sure it exceeds your upload_max_filesize setting. The post_max_size looks at the entirety of the form submission, including submitted fields beside the upload (if you have any). You could run into an issue, for example, if post_max_size equaled upload_max_filesize, uploaded a file right around the maximum size, but also had some input fields that caused the form submit data to exceed the total allowed size. It's an edge case, but easy to avoid.
<Disease />
(Feb 6, 2019 08:59 PM)Disease Wrote:  Just as a head's up, you may need to increase your max_input_time directive.  By default, per the documentation, it'll use whatever your max_execution_time setting is.  I wouldn't advise changing that though.  The max_input_time directive is specifically for parsing input data- such as the file(s) being uploaded.

Also, and I'm assuming you fixed this if you're no longer having issues, be mindful of post_max_size.  Per the documentation, make sure it exceeds your upload_max_filesize setting.  The post_max_size looks at the entirety of the form submission, including submitted fields beside the upload (if you have any).  You could run into an issue, for example, if post_max_size equaled upload_max_filesize, uploaded a file right around the maximum size, but also had some input fields that caused the form submit data to exceed the total allowed size.  It's an edge case, but easy to avoid.

Thanks, fixed it already but I appreciate the help


Possibly Related Threads...
Thread / Author Replies Views Last Post
[PHP] by AussieMay 3, 2020 06:00 AM 2 142 May 3, 2020 06:00 AM
Last Post: Aussie
[PHP] by BulgarianFeb 21, 2020 12:33 AM 5 372 Feb 21, 2020 12:33 AM
Last Post: Backbone
[PHP] by Account of the GodsMar 25, 2018 03:09 PM 12 472 Mar 25, 2018 03:09 PM
Last Post: SIM-2223238