JoeGandy / ShareX-Custom-Upload

A little PHP script created for uploading custom sharex files to your own webserver
MIT License
165 stars 50 forks source link

File upload failed, ensure permissions are writeable (777) on the upload directory #156

Closed MAXOUXAX closed 2 years ago

MAXOUXAX commented 2 years ago

I get this error every time I try to upload a file from ShareX, and even after redefining the permissions, the error still appears. Here are the two commands I ran: sudo chown -R www-data:www-data release/ sudo chmod -R 755 release/

theaquarium commented 2 years ago

Can you make sure that the permissions are writable on your file upload folder? (Probably release/u/)

davwheat commented 2 years ago

I started having the same issue the other day.

Make sure there is storage space left on your root partition of your web server. This is where files are stored temporarily before being saved to disk in your uploads folder, I believe.

MAXOUXAX commented 2 years ago

Can you make sure that the permissions are writable on your file upload folder? (Probably release/u/)

Yes, all folders and files have the right permissions. Screenshot

I started having the same issue the other day.

Make sure there is storage space left on your root partition of your web server. This is where files are stored temporarily before being saved to disk in your uploads folder, I believe.

Yes, there is enough storage space and inodes available to create new files. Screenshot

NotGeri commented 2 years ago

I am having the exact same issue on Ubuntu 20.04. I have plenty of storage space left and I have the exact set of permissions as @MAXOUXAX

I am trying to re-create the issue but it seems completely random.

JoeGandy commented 2 years ago

I would check you're not hitting max upload size, try a really small file? See: https://github.com/JoeGandy/ShareX-Custom-Upload/issues/8

JoeGandy commented 2 years ago

We should probbably look into adding errors and checking them against max upload size limits in php to make the errors more clear

MAXOUXAX commented 2 years ago

I would check you're not hitting max upload size, try a really small file? See: #8

Just tried with a 1 Ko text file, same issue. The problem with this error is that it is triggered by a PHP method, which can fail for many reasons. However I don't see what is bothering PHP, the permissions are set correctly, there is enough free disk space and the upload limit is not exceeded.

JoeGandy commented 2 years ago

Yeah you're absolutely right on the error being super generic, Any more info in the php error logs?

MAXOUXAX commented 2 years ago

There are no errors in the PHP error logs, however I just noticed that an error is sent in the nginx logs.

2021/10/22 10:40:11 [error] 14848#14848: *55 FastCGI sent in stderr: "PHP message: PHP Warning:  Undefined array key 
"fileupload" in /usr/share/nginx/html/xxxxx.xxxxx.xxx/release/upload.php on line 15PHP message: PHP Warning:  Trying to access
 array offset on value of type null in /usr/share/nginx/html/xxxxx.xxxxx.xxx/release/upload.php on line 15PHP message: PHP 
Warning:  Undefined array key "fileupload" in /usr/share/nginx/html/xxxxx.xxxxx.xxx/release/upload.php on line 24PHP message: 
PHP Warning:  Trying to access array offset on value of type null in /usr/share/nginx/html/xxxxx.xxxxx.xxx/release/upload.php on 
line 24PHP message: PHP Warning:  Undefined array key "fileupload" in 
/usr/share/nginx/html/xxxxx.xxxxx.xxx/release/upload.php on line 37PHP message: PHP Warning:  Trying to access array offset on
 value of type null in /usr/share/nginx/html/xxxxx.xxxxx.xxx/release/upload.php on line 37PHP message: PHP Warning:  
Undefined array key "fileupload" in /usr/share/nginx/html/xxxxx.xxxxx.xxx/release/upload.php on line 50PHP message: PHP 
Warning:  Trying to access array offset on value of type null in /usr/share/nginx/html/xxxxx.xxxxx.xxx/release/upload.php on line 
50" while reading response header from upstream, client: xxx.xxx.xxx.xxx, server: xxxxx.xxxxx.xxx, request: "POST /upload.php 
HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php8.0-fpm.sock:", host: "xxxxx.xxxxx.xxx"
JoeGandy commented 2 years ago

Ok that gives us some more to go off, how are you uploading the file, through sharex? through the web inteface?

It seems to think you haven't passed a file into the POST script and $_FILES['fileupload'] is empty

MAXOUXAX commented 2 years ago

Ok that gives us some more to go off, how are you uploading the file, through sharex? through the web inteface?

It seems to think you haven't passed a file into the POST script and $_FILES['fileupload'] is empty

I'm trying to upload files through ShareX - upload is working fine with the web interface.

MAXOUXAX commented 2 years ago

Alright then, I don't really know how it happened, but somehow my ShareX custom uploader got messed up and fileupload became d. Problem solved!

JoeGandy commented 2 years ago

Awesome, Yeah i was just about to suggest that, Did you use the auto config generator for shareX it could be an issue in that?

MAXOUXAX commented 2 years ago

Awesome, Yeah i was just about to suggest that, Did you use the auto config generator for shareX it could be an issue in that?

I was using the configuration generated from the website, and it worked fine, but I guess I accidentally changed a field at some point and it broke the uploader?