php - how to understand file size is more than FILE_MAX_SIZE and send error? -


in form used 2 file input , set max_file_size each of them, when submit form files bigger max_file_size doesn't thing. how can handle , report user's files bigger max size? can php upload class when use max_file_size didn't work or mybe class not invoked @ 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 used on client side of browser. therefore, can't trust it.

when file on php size, control size manually:

if ($_files["comp_file"]["size"] > 1024 * 1024 * 8){ //8mo, adjust need     exit("file big"); } 

obvisouly, exit little harsh. adapt need.


Comments