File tree Expand file tree Collapse file tree 3 files changed +25
-2
lines changed
Expand file tree Collapse file tree 3 files changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,9 @@ RUN mkdir -p /var/log/nginx
2323# php stuff
2424RUN sed -i 's/nobody/nginx/g' /etc/php83/php-fpm.d/www.conf
2525RUN sed -i 's/E_ALL \& ~E_DEPRECATED \& ~E_STRICT/E_ALL \& ~E_DEPRECATED \& ~E_STRICT \& ~E_NOTICE \& ~E_WARNING/g' /etc/php83/php.ini
26+ # disable upload file size limit
27+ RUN sed -i 's/upload_max_filesize = 2M/upload_max_filesize = 0/g' /etc/php83/php.ini
28+ RUN sed -i 's/post_max_size = 8M/post_max_size = 0/g' /etc/php83/php.ini
2629
2730# web interface stuff
2831WORKDIR /var/www/backupdrop/web/lib
Original file line number Diff line number Diff line change @@ -82,8 +82,14 @@ function handleUpload($hostname)
8282 }
8383 else //some upload error
8484 {
85- http_response_code (404 );
86- return ['status ' =>'error ' ,'reason ' =>'No file uploaded ' ];
85+ $ error = $ _FILES ["file " ]["error " ];
86+ if ($ error == 1 || $ error == 2 )
87+ http_response_code (413 );
88+ else if ($ error == 3 )
89+ http_response_code (500 );
90+ else
91+ http_response_code (404 );
92+ return ['status ' =>'error ' ,'reason ' =>'No file uploaded ' ,'error ' =>uploadErrorTranslator ($ error )];
8793 }
8894}
8995
Original file line number Diff line number Diff line change @@ -72,4 +72,18 @@ function endsWith( $haystack, $needle ) {
7272 return true ;
7373 }
7474 return substr ( $ haystack , -$ length ) === $ needle ;
75+ }
76+
77+ function uploadErrorTranslator ($ code ){
78+ return match ($ code )
79+ {
80+ 0 => 'There is no error, the file uploaded with success ' ,
81+ 1 => 'The uploaded file exceeds the upload_max_filesize directive in php.ini ' ,
82+ 2 => 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form ' ,
83+ 3 => 'The uploaded file was only partially uploaded ' ,
84+ 4 => 'No file was uploaded ' ,
85+ 6 => 'Missing a temporary folder ' ,
86+ 7 => 'Failed to write file to disk. ' ,
87+ 8 => 'A PHP extension stopped the file upload. '
88+ };
7589}
You can’t perform that action at this time.
0 commit comments