php - Server side file validation -
i'm trying make file upload server form:
<form action="send_valid.php" method="post" enctype= "multipart/form-data"> <br> <input type="file" name="pdf" id="pdf" accept="application/pdf"/> <input type="hidden" name="max_file_size" value="10000000"/> <input type="submit" value="wyĆlij"> </form> and want allow user send pdf files of max size 10mb.
my php configuration uploads is:
file_uploads = on upload_tmp_dir = "e:\xampp\tmp" upload_max_filesize = 11m max_file_uploads = 20 post_max_size = 12m to check file size use:
if($_server["request_method"] == "post"){ var_dump($_files); if(extract($_files)){ if($pdf['size']>10000000){ echo "file size large!"; } } now want show user error (for now) echo when file big. works fine if lower 10mb (even code above works when change size 1mb , file larger display echo), files of 10mb , above produces error:
warning: post content-length of 11450416 bytes exceeds limit of 8388608 bytes in unknown on line 0 array(0) { } i don't have clue why shows exceeds 8mb since in configs couldn't find 8mb anywhere.
where can problem? there way catch upload exceeds configuration setting not show user php server error?
and if want make file validation above method , checking file extension examle:
$ext = pathinfo($_post['pdf'], pathinfo_extension); is enough? insight on file validation helpful.
update values of post_max_size , upload_max_filesize in php configuration file.
note values measured in bytes.
Comments
Post a Comment