Reputation: 657
I am uploading a file to database using php. May I know why I am not getting any amount of size when I upload? When I print_r($_FILES)
on the size it return:
Array
(
[uploaded] => Array
(
[name] => Array
(
[0] => f2-CP-2016.pdf
[1] =>
[2] =>
)
[size] => Array
(
[0] => 0
[1] => 0
[2] => 0
)
I have upload a file but the size still return 0. I want to make a validation for size > 3MB
it will return an error. Below are my codes:
for($i=0; $i < count($_FILES['uploaded']['name']); $i++){
$array = array($_FILES['uploaded']['name']);
$tmpFilePath = $_FILES['uploaded']['tmp_name'][$i];
$filesize_upload = $_FILES['uploaded']['size'][$i];
if($filesize_upload > 3145728){
die('File is BIG');
} else {
//proceed to upload
}
}
Update with error:
This is the error that I received
[error] => Array
(
[0] => 1
[1] => 4
[2] => 4
)
Upvotes: 1
Views: 238
Reputation: 2168
Check the error index in the uploaded array... you might have a code which defines the error nature.
Upvotes: 1