[RESOLVED] Error caught when Uploading file larger than 100KB

image

Caught this when uploading files greater than 100kb. Tried some file that 117kb in size works. but larger than that Getting this error.

Hope I can get some idea or help regarding this issue.

P.S.
I already configured php.ini (max file size, etc) and also in application/config/grocerycrud.php (upload_max_file_size)

Thank you all

Hello @entrylvlSE and welcome to our forums :grinning:

Usually the issue that you can’t see the error message is that the error reporting is not showing the error message. In order to see the error try for debugging the following instructions: How do I get PHP errors to display? - Stack Overflow

Now for your specific issue since the default value oh php.ini for upload_max_file_size is 100KB I don’t think that this is a coincidence. Please try to restart Apache to apply the changes. If this is still not working then maybe the php.ini file is on different folder.

Try creating a file with name phpinfo.php and add the following lines:

<?php
phpinfo(); 

This will print the configurations of PHP that you are using. Search for php.ini and you will see the location of your php.ini file as you can also see at the screenshot:

Please let me know if that worked for you.

Regards
Johnny

1 Like

Sir Johnny, Thank you for your response

Thats my php information.

Is it correct that the conf file is diff from loaded conf file?

And also the PHP Error configuration is already set. yet no error are showing.

Thank you Sir

Hello @entrylvlSE yes that’s correct the C:\php\php.ini file is the file that you should change. Also make sure that you’ve also restarted Apache or else the changes will not be applied.

Last but not least it seems that you are using PHP version 5.6.30 which we silently not support. I would suggest you to upgrade to PHP version 7 or later (if possible) as you may experience other issues with the library as well.

Regards
Johnny

1 Like

Good Day Sir @johnny,

I already edited that file but same error occurs.

We are already in process of upgrading our PHP version.

Thank you for your quick and vast response.

Thank you!

Good day Sir Johnny

What is your recommended version to properly use GCRUD Latest Version
php v?
Codeigniter v?

Thank you

Hello @entrylvlSE ,

I would suggest latest Codeigniter version and latest PHP version if possible:

Codeigniter v4.2.10
PHP version v8.1

Regards
Johnny

1 Like

Thank you Sir Johnny.

I will consider your suggestion.

But I’m still confused why I’m encountering that kind of error when uploading. Hope I can still get some answers.

Thank you Sir Johnny.

Hello @entrylvlSE ,

Back to your problem. From my experience when there are some upload limitations then the error is not reported from PHP (e.g. it can’t handle it and it is showing a blank page). I strongly believe that the issue is still that the configuration is not updated. Can you attach the screenshot of phpinfo by searching upload_max_filesize as you can also see at the below screenshot?

Also so I can help more, what Codeigniter version are you using?

Regards
Johnny

1 Like

Thank you Sir for responding.

I am currently using Codeigniter 3.1.4.
GCRUD Version 2.7.9

image

Hello @entrylvlSE ,

Can you also check few more configurations?

max_execution_time, max_file_uploads, max_input_time, output_buffering, memory_limit, post_max_size

Also screenshot for the info:

If this is still doesn’t work then I am not convinced that it picked up the correct configuration still :grinning:. Can you open the page with the enterprise version and instead of loading the CRUD (e.g. $crud->setTable()… e.t.c.) to output the below code and let me know the output please?

var_dump(ini_get('upload_max_filesize'));
exit;

and see if this is corresponding the correct value for you? My blind guess would be that you have 2 PHP installed into your machine. If this is the case you will need to find the second php.ini file and do the change there as well.

Regards
Johnny

1 Like

Good Day Sir Johnny.

Thank you again for your fast response and will to help me out of this problem.

This is what I got from running the code. Its the same from the configuration.

That’s very weird then. The only thing that you can do here is to debug it a little bit if this is not a big issue for you. Go to the file: application/libraries/GroceryCrudEnterprise/grocerycrud/enterprise/src/GroceryCrud/Core/State/UploadState.php and start debugging it to see where the issue is. More specifically go to the line 26 and start adding some var_dump . For example:

public function render()
    {
        var_dump('hello');
        die;
        $stateParameters = $this->getStateParameters();

        $this->setModel();
        $model = $this->gCrud->getModel();

        $this->initializeLight($model);

If this will work try to move the:

        var_dump('hello');
        die;

to a lower line to see where the issue is. My blind guess will be that this is not even going to the “render” function and PHP is blocking it.

1 Like

Good Day Sir Johnny. I tried to add var_dump inside the render function. Please check the uploaded image for reference.

When I upload a file 100kb less, I get the var_dump message hello, but when I upload 100kb more I get the error (reading body) just like the first picture I uploaded on this forum.

I tried adding @ in array_keys($_FILES)[0] then I upload a file 400kb in size. I prompted to the error message (‘This operation is not allowed’);

image

I have no idea of what is currently happening.

But I continuing to debug but I need some help.

Thank you

Regards,
@entrylevelse

I tried to dump the $field_name and it says NULL (When uploading 100kb larger file)

It outputs up_projprop (my field in db) when I upload 100kb file.

What does that mean?

I also tried to print_r $_FILE details.

when I upload a large file i get this error from my apache error.log
image

I upload a 100kb file this is what I get

Hello @entrylvlSE ,

Also a blind guess from your report. I’ve noticed that the memory limit is also low on your PHP. Can you please change the memory_limit from 60MB to 512MB ?

Let me know if that worked.

Regards
Johnny

1 Like

Also googling around seems that the ModSecurity also have some limitations on upload. Can you check this post here: Apache server reverse proxy: increase file upload limit - Stack Overflow. and try to change the SecRequestBodyLimit and SecRequestBodyInMemoryLimit configurations?

This configuration seems that it is on Apache from what I see here: Configuring mod_security so if that doesn’t work maybe try to disable the mod_security plugin temporarly (since you are running it locally) and try again? Don’t forget to always restart Apache as well.

Regards
Johnny

1 Like

Good Day Sir @johnny

Thank you for the vast support facing this problem.

After hours of googling and researching, I found the root of the problem.

The upload_tmp_directory is disabled. After setting up an temporary directory, the upload works. I’m not quite sure if that’s the reason but I’m happy it worked.

Thank you again for your support and help Sir @johnny.

Regards,
@entrylvlSE

1 Like