Welcome Guest, Not a member yet? Register   Sign In
How to deal with large uploads (no error message received)?
#1

Assume I have a form that allows to upload large files together with short strings. The post method is used for the upload.

Problems arise when the uploaded files are larger than the maximum upload file limit because it seems to be that I do not get an error message. And I have no idea how to detect that something went wrong.

The controller's method to deal with the form is correctly called. When inspecting inside the controller's method a couple of $this->request->getPost('...') results I get NULL for all inspected variables: for the large uploaded file and for the short strings.

I also made a var dump of $this->request. It can be seen that the small short strings and the large uploaded file exist in the body of request. But the post and get arrays as well as the files array are empty.

Does anybody have a suggestion how to deal with this issue?
Reply
#2

You need to edit your php.ini file and change the below parameters.

CHANGING THE MAXIMUM UPLOAD FILE SIZE

By default, the maximum upload file size for PHP scripts is set to 128 megabytes. However, you may want to change these limits.
For example, you can set a lower limit to prevent users from uploading large files to your site. To do this, change the
upload_max_filesize and post_max_size directives in your php.ini file.

To ensure that file uploads work correctly, the post_max_size directive should be a little larger than the upload_max_filesize.
For example, the following settings demonstrate how to set a file upload limit to 20 megabytes:

Code:
upload_max_filesize = 21M
post_max_size = 21M

Change to the largest size that you want for uploading, these values should match.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

@InsiteFX: Thanks for the answer. Yes, I know that I can change the limits. But actually I would like to get from CodeIgniter any kind of feedback that there is a problem.

I was not surprised that I did not get the large file in any of the post or files arrays but I did not expect that the strings sent together with the large file were not visible. And this resulted actually in an unexpected crash of my app because the post parameters of the strings were not found. Frankly speaking, I do not know if this is a PHP issue or a CodeIgniter issue.
Reply
#4

Are you storing your files on your own server? If you're using something like AWS or Azure, you can upload your file directly to a file store so you don't run into file size issues on your server. It's usually much quicker too.
Codeigniter is simply one of the tools you need to learn to be a successful developer. Always add more tools to your coding arsenal!
Reply
#5

(01-22-2019, 09:19 AM)albertleao Wrote: Are you storing your files on your own server? If you're using something like AWS or Azure, you can upload your file directly to a file store so you don't run into file size issues on your server. It's usually much quicker too.

@albertleao: no.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB