I am working with multiple file upload in PHP and I also fixed an upload limit of 10MB using the following HTML commands in an upload form PHP file:
<input type="hidden" name="MAX_FILE_SIZE" value="10000000">
<input id="infile" type="file" name="infile[]" multiple="true" />
In the PHP file that takes care of upload function I was initially expecting that if I try to upload a file of size greater than 10MB then the function call statement
move_uploaded_file($_FILES['infile']['tmp_name'][$i], $dir . $fPath);
will fail and I can show an "Error upload file of size less than 10MB" message. But it didnt happen. It was trying to upload and it didnt display any error message as expected.
So I tried to restrict the file size specifically in the code by using the if statement as:
if ($_FILES["infile"]["size"][$i]<10000000)
{
move_uploaded_file($_FILES['infile']['tmp_name'][$i], $dir . $fPath);
}
else
echo "error";
But still it doesnt echo error as expected. Can anyone please point out the mistake I am doing here?