Limit file size upload
Hey guys
I don't know how to work with the git system, so I leave the change here
Add code (line 509)
// check file size (limit to 10 MB)
if($attachment['size'] > 10 * 1024 * 1024) {
// error
echo json_encode(array("error"=>1,"code"=>"file_too_large","size"=>$attachment['size']));
// return
return false;
}
after end tag } of code
// error
echo json_encode(array("error"=>1,"code"=>"file_not_allowed","file"=>$attachment));
// return
return false;
}
Please review security
File size is also limited by your web-server AND php.
nginx in any server, http or location:
client_max_body_size 10M;
apache in .htaccess:
LimitRequestBody 10485760
php in php.ini (most likely the fpm one):
upload_max_filesize = 10M
You'll get a 413 Request Entity Too Large from your web-server or file_error from php if you exceed these.
Thanks @TheNeoBurn.
However, I have a question: what is the best way to implement ensuring the addition of the upload value through wikidocs menu?
Thanks,
@ffiesta,
The issue is that both the web-server and php set the upper limit for WikiDocs as long as it uses the default file upload method. This means that WikiDocs could only ever be configured below these limits.
If WikiDocs works under a general web-server with a huge file upload setting or if it changes to another method for uploading big files then yes, this would be a nice feature.
Note: Also, I did the pull-request thing for the first time here today and can now tell you how: Create a fork, edit the code in your own repository created by the fork, then return to this repository and GitHub will scream at you that you have changes and asks you to create a pull request.
Done, but
- on php > 8.0 + it give an error
[30-Mar-2024 14:32:26 UTC] PHP Warning: Undefined array key "document" in /home/pmtpt1/public_html/wiki/submit.php on line 456 - on php > 8.1 + it give an error on same line but show that
deprecated strtolower()
hi @ffiesta, at this moment wiki|docs is based on php 7.. we have not ready yet converted it to fully support php 8. i will try to do this conversion in the next months i am very busy with my work in this period, sorry!
Hi @Zavy86, yap this work with php 7.
In future i will try to make a menu.
Thanks