Изборник Затворити

How to properly handle too large file uploads through forms in PHP

Скраћена веза: https://pedja.supurovic.net/veza/10160

Handling HTML forms in PHP seems like straightforward task. Usually it is  – until you meet some edge cases. On of such cases is handling when user tries to upload too large file using the form.

PHP has setting for file upload limitations. Parameter is called upload_max_filesize. By default it is set to 2 MB which means PHP would not allow files larger than 2MB to be handled by form.

How do you handle such case? It is quite simple: PHP would return uploaded file size (in $_FILES) as zero. All you have to do is check for file size and if it is equal to zero, file was to large and PHP did not allow upload. […]
[ ... види цео чланак ... ]