$_FILES['size'] File is too large...
Posted: Fri Jul 30, 2004 7:16 pm
I'm creating a file upload page. My server has a restriction of 2MB per file. This is fine, however, I want to inform the user that the reason the file didn't upload was because it is too large. I attempted to solve this by using the following code:
This is what the $_FILES looks like:
Is there a way for me to determine the file size before the server throws the error?
Also, how can I change the 2 MB limit?
Code: Select all
<?php
foreach($_FILES as $a_file){
//CALCULATE TOTAL FILE SIZES
$total_file_size += $a_file['size'];
}
if($total_file_size>BYTES_IN_ON_MEG*2){
//INFORM USER
}
?>Code: Select all
<?php
Array
(
[new_file_0] => Array
(
[name] => dream car.mpeg
[type] =>
[tmp_name] =>
[error] => 1
[size] => 0
)
[new_file_1] => Array
(
[name] => IMG_0704.jpg
[type] => image/pjpeg
[tmp_name] => /tmp/php0xtsin
[error] => 0
[size] => 883720
)
)
?>Also, how can I change the 2 MB limit?