Articles in this section

How to upload big files in php?

To upload more than 65MB file on a PHP container.

Assumptions

You are running PHP

Problems

When you have a form where your clients upload a file they receive an error like the following

POST Content-Length of 148883898 bytes exceeds the limit of 67108864 bytes in Unknown on line 0

 

Steps

In .upsun.app.yaml add the following variables and adjust the size accordingly. Here I have set it to 1GB.

variables:
    php:
        post_max_size: '1024M'
        upload_max_filesize: '1024M'

Then under the web and locations add the following (adjust accordingly the root path and the focus is only the request_buffering here and not the root or pass through)

# The configuration of app when it is exposed to the web.
 web:
    locations:
        "/":
            # The public directory of the app, relative to its root.
            root: "web"
            # The front-controller script to send non-static requests to.
            passthru: true
            #To allow 580MB file
            request_buffering:
              enabled: true
              max_request_size: 600m

 

Conclusion

NOTE: This has to be done carefully because if your container size is like 128MB RAM and multiple uploads happen then PHP will be killed with OOM as it will run out of RAM.

Also you should monitor your disk space as well. So please keep an eye for this. If PHP is getting killed then you may to increase the plan or contact support.

Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.