sjarvela / kloudspeaker

Document management system
GNU General Public License v2.0
95 stars 40 forks source link

Error with upload files #123

Open mrcivic opened 8 years ago

mrcivic commented 8 years ago

Hi! I have an error, when I try to upload any files "File upload failed"

2016/04/03 02:44:30 [error] 5213#0: *12 FastCGI sent in stderr: "PHP message: KLOUDSPEAKER ERROR: ServiceException: INVALID_REQUEST=Invalid FilesystemServices request: POST 
PHP message: KLOUDSPEAKER ERROR: {0:{file:/var/www/devel/kloudspeaker/backend/include/services/FilesystemServices.class.php, line:369, function:invalidRequestException, class:ServicesBase, type:->, args:{}}, 1:{file:/var/www/devel/kloudspeaker/backend/include/services/FilesystemServices.class.php, line:67, function:processPostFolder, class:FilesystemServices, type:->, args:{0:FILESYSTEMITEM Folder (LocalFilesystem): [57004a6c991e8] = 'test' ()}}, 2:{file:/var/www/devel/kloudspeaker/backend/include/services/ServicesBase.class.php, line:69, function:processPost, class:FilesystemServices, type:->, args:{}}, 3:{file:/var/www/devel/kloudspeaker/backend/include/KloudspeakerBackend.class.php, line:85, function:processRequest, class:ServicesBase, type:->, args:{}}, 4:{file:/var/www/devel/kloudspeaker/backend/r.php, line:81, function:processRequest, class:KloudspeakerBackend, type:->, args:{0:Request}}}" while reading response header from upstream, client: 1.1.0.250, server: devel.derr.ru, request: "POST /kloudspeaker/backend/r.php?sp=filesystem/57004a6c991e8/files/?format=binary HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "devel.derr.ru", referrer: "http://devel.derr.ru/kloudspeaker/?v=files/57004a6c991e8"

I saw this topic: https://github.com/sjarvela/kloudspeaker/issues/93

but adding the "service-param": true, and

location /kloudspeaker {
            try_files $uri $uri/ /kloudspeaker/backend/r.php?$args;
        }

had no effect to me.

Here is my nginx host conf

server {

        listen 80;
          access_log off;
          error_log  /var/log/nginx/devel.derr.ru.error.log;
        #  ssl on;
        #  ssl_certificate /etc/nginx/ssl/webserver.crt;
        #  ssl_certificate_key /etc/nginx/ssl/webserver.key;
        root  /var/www/devel;
        server_name devel.derr.ru;
        server_tokens off;
        index index.html index.php;  

   location ~* \.php$ {   
        fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_script_name;
        # 
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;

        # With php5-cgi alone:
        fastcgi_pass 127.0.0.1:9000;
        # With php5-fpm:
        #fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params; 

        fastcgi_connect_timeout 60;
        fastcgi_send_timeout 60;
        fastcgi_read_timeout 60;
        fastcgi_buffer_size 128k;
        fastcgi_buffers 4 256k; 
        fastcgi_busy_buffers_size 256k;
        fastcgi_temp_file_write_size 256k;
        fastcgi_intercept_errors on;

        client_max_body_size       10m;
        client_body_buffer_size    128k;
        expires off;
        proxy_set_header   Host             $host;
        proxy_set_header   X-Real-IP        $remote_addr;
        proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
        #fastcgi_pass unix:/var/run/php5-fpm.sock;
    }
            location / {
            try_files $uri $uri/ =404;
        #   auth_basic "Restricted Content";
        #   auth_basic_user_file /etc/nginx/.htpasswd;
            proxy_redirect off;
            client_max_body_size       10m;
            client_body_buffer_size    128k;
            proxy_connect_timeout      90;
            proxy_send_timeout         90;
            proxy_read_timeout         90;
            proxy_buffer_size          1024k;
            proxy_buffers              8 5120k;
            proxy_busy_buffers_size    10240k;
            proxy_temp_file_write_size 10240k;
            proxy_set_header   Host             $host;
            proxy_set_header   X-Real-IP        $remote_addr;
            proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
            expires off;    
        }

        location /kloudspeaker {
            try_files $uri $uri/ /kloudspeaker/backend/r.php?$args;
        }

}

How can I fix it??

Thank in advance!

sjarvela commented 8 years ago

The error sounds like the request forwarded to the PHP does not have the all the request path parts.

The error is "invalid request" coming from FilesystemServices line 369, which is function "processPostFolder" checking right in beginning that there should be further items in path, and since there is none, it throws this error.

The upload request is like this: "/filesystem/[parent_id]/items", where parent_id is the upload target. Since it goes to "processPostFolder", it means it is POST request for a filesystem item that is identified as a folder. So, it at least gets the "parent_id" part, but it sounds like it would not get the "items" part at all.

The log does not reveal the request info, this could show some more info, but perhaps the nginx/url rewrite configuration would not keep all parts in the request?

OutsourcedGuru commented 8 years ago

For what it's worth, I was receiving the "File upload failed" error for files larger than 2MB. I followed the instructions here but it doesn't say where to find that php.ini file. A google search suggests that it's /etc/php5/apache2/php.ini that you want but I found that the one that worked was actually /etc/php/7.0/apache2/php.ini on Ubuntu, at least.

GersonLazaro commented 8 years ago

@OutsourcedGuru check https://github.com/sjarvela/kloudspeaker/wiki/Uploader#stream-upload

OutsourcedGuru commented 8 years ago

@GersonLazaro I got that to work by editing the php.ini file. My point was that there are two php.ini files on my Ubuntu, the actual one being the non-obvious.