Issue uploading files

Hi,

i installed the last version of leadtime (v2.1.0) on my linux server, nginx and php7.3.
Web server is running with the user “www”, i gave to the “www/userfiles” and “www/public/userfiles” the ownership to “www” with the right 755, but i still get an error message in leantime: "File could not be uploaded "
Unfortunaltely the php / nginx logs only gave that message:
2020/05/03 11:05:16 [warn] 4125#4125: *1 a client request body is buffered to a temporary file /var/lib/nginx/tmp/client_body/0000000001, client: 192.168.1.40, server: localhost, request: “POST /tickets/showTicket/12 HTTP/2.0”, host: “192.168.1.116”, referrer: “https://192.168.1.116/tickets/showTicket/12

nothing else :frowning: any idea how to move forward?

Thanks

Do you see any other errors in resources/logs/error.log?

Thanks you for your Quick answer.

Unfortunately this log file does not have any récent record.
Is there any config file to modify, in ordre to increase the debug détails?

Try setting the $debug flag in config/settings.php

Hi

I changed the debug flag in the config/settings.php to private $debug = 1;
my nginx variable are: set $base /www/; and root $base/public;
so the log should be /www/resources/logs/error.log
but this file remains empty of new records, even after restart of the server and new tasks done in the app.

i set all log file rights to 666 in order to be sure they work.

regards

Okay, let’s try something more unconventional:
Open src/core/class.fileupload.php

In Line 291 add else { throw new \Exception("Upload failed"); }

In Line 295 add var_dump($e->getMessage());

so that that method looks like:

private function uploadLocal() {
        try {

            if (move_uploaded_file($this->file_tmp_name, $this->getAbsolutePath() . "/" . $this->file_name)) {
                return true;
            }else { throw new \Exception("Upload failed"); }

        }catch(\Exception $e){
            var_dump($e->getMessage());
            error_reporting($e->getMessage());
            return false;
        }

        return false;

    }

Thanks again for the quick answer.

Something strange, even with your change, the /www/resources/logs/error.log remains empty.

On the other hand, the nginx error file writes that:

2020/05/03 19:37:40 [warn] 4159#4159: *1 a client request body is buffered to a temporary file /var/lib/nginx/tmp/client_body/0000000002, client: 192.168.1.40, server: localhost, request: “POST /tickets/showTicket/15 HTTP/2.0”, host: “192.168.1.116”, referrer: “https://192.168.1.116/tickets/showTicket/15

is it normal that the /var/lib/nginx/tmp/client_body/ remains empty?

Until now, i always tried to attached a document to a ‘task’, now I did another test, this time trying to attach a picture to a message.
and this is the result:

localhost, request: “POST /api/files HTTP/2.0”, host: “192.168.1.116”, referrer: “https://192.168.1.116/ideas/advancedBoards
2020/05/03 19:59:22 [error] 4159#4159: *79 “/www//public/ideas/index.php” is not found (2: No such file or directory), client: 192.168.1.40, server: localhost, request: “GET /ideas/ HTTP/2.0”, host: “192.168.1.116”, referrer: “https://192.168.1.116/ideas/advancedBoards

in the nginx config file, i replaced the ‘base’ variable for this:
set $base /www;
root $base/public;

which get rid of the error message, but still no way to upload anything
maybe that helps

Hey,

Sorry for asking a silly question but how big is your file? I usually work with apache so I forgot to ask that question earlier, but it seems nginx has a default file size limit of 1MB
https://www.tecmint.com/limit-file-upload-size-in-nginx/

If that is not the problem, follow allong here:
The idea thing is a separate issue I believe, so lets track that later (hoping this will be resolved with the original problem).

The var_dump() function I gave you should have printed a message that you would have seen. That leads me to believe that the entire method is not being called, which means there is a problem earlier in the chain.

This is going to be a little bit tedious but bear with me:

Please add

var_dump($file);

in /src/domain/files/services/class.files.php in line 33

and

var_dump($upload);

in src/domain/files/repositories/class.files.php in line

Let’s see if that sheds some light on the point of failure.

Beside Marcel’s support,
If you want to upload large file, you can configure /usr/local/etc/php/conf.d/custom.ini (with docker):
memory_limit = 1G
file_uploads = On
upload_max_filesize = 512M
post_max_size = 512M
max_execution_time = 360
I have same problem with other version (2.1 beta6), and i try to configure it. After that, it run OK.

Regards!

Thank you Mike, but i already had similar settings in my ‘php.ini’ file (’/etc/php7/php.ini’ no docker used).

Thank you Marcel,

  • my test file is 8k, in that case, size does not matter :wink:
  • i did the change into the /src/domain/files/services/class.files.php at line 33:
    public function uploadFile($file, $module, $entityId, $entity) {

var_dump($file);
if (isset($file[‘file’])) {

  • as you did not specified the line number for the other change ‘src/domain/files/repositories/class.files.php’ i did the change at line 226
    public function upload($file,$module,$moduleId)
    {
        $upload = new core\fileupload();

var_dump($upload);

even with those changes both log files remains “clean”:

  • /var/log/nginx/leantime.error.log --> empty
  • resources/logs/error.log --> empty

Note: in order to ensure the log files are working, i did an additional test: uploading a huge file, bigger than the Allowed_memory_size, and in that specific case i get an error in the resources/logs/error.log. So, my conclusion is that log system is working fine…

so with those additional var_dumps you see nothing strange printed on the screen? It should give you a variable dump of those variables.

Ohh. I see. There is a redirect which would cause the dumps to be cleared.
One more thing in class.showTicket.php line 206 comment out

$this->tpl->redirect(BASE_URL."/tickets/showTicket/".$id);

like so

//$this->tpl->redirect(BASE_URL."/tickets/showTicket/".$id);

(This will break saving your to-dos, so only do this for debug purpose and then uncomment)

Hi Marcel,

i modified : src/domain/tickets/controllers/class.showTicket.php
and now, when i try to attach a file to a “todo task” https://192.168.1.116/tickets/showTicket/15#files
then i get a blank web page, with this content:

<html><head></head><body>array(0) {
}
</body></html>

does it help?

Regards

This is bizarre. It seems $_FILES is not set which indicates either size issues or nginx can’t access the folders at all. Can you check your configuration again and make sure the temp folder for nginx is accessible?

I found the error !!!

in my php.ini file this parameter is by default not set:

max_file_uploads =

which defines how many files could be uploaded in a raw.

I changed it to :

max_file_uploads = 100

and now LeanTime is working with file upload!!

Thanks to everybody for helps
-> issue solved :grinning:

Awesome! I am glad this got resolved. I do wonder why your PHP config didn’t set max_file_uploads. In nay case this is good to know and I’ll make sure to include that case in our docs!