In my form i used two file input and set the MAX_FILE_SIZE for each of them, when i submit form with files bigger than MAX_FILE_SIZE it doesn't do any thing. how can i handle this and report user's files are bigger than max size? i can do it with a php upload class but when i USE MAX_FILE_SIZE that it didn't work or mybe the class not invoked at all.
<div class="form-group">
<label for="comp_file">فایل فشرده : </label>
<input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $max_zipfile_size; ?>" >
<input type="file" name='comp_file' class="form-control" id="comp_file">
<p class="help-block">فایل قابل دانلود را انتخاب کنبد.
فایل باید در حالتد فشرده قرار داشت باشد.</p>
</div>
<div class="form-group">
<label for="file_image">عکس مربوط به مقاله : </label>
<input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $max_image_size; ?>" >
<input type="file" name='file_image' class="form-control" id="file_image">
<p class="help-block">در صورتی که عکسی مناسب با مقاله در اختیار دارید ارسال کنید.</p>
</div>
MAX_FILE_SIZE
is used on the client side of browser. Therefore, you can't trust it.
When you get the file on the PHP Size, control its size manually:
if ($_FILES["comp_file"]["size"] > 1024 * 1024 * 8){ //8mo, adjust as you need
exit("File too big");
}
Obvisouly, this exit
is a little to harsh. Adapt it to something you need.
Use java script to validate to user for maximum file size uploading,if file size is greater than maximum file size than alert a message to user and stop to submit the action. or you can check file size at server size and populate an warning message to user by using php itself.