I\'ve created a form with 3
I see that I get an array with array(name=>\"\")
.
So I check if (
There is: is_uploaded_file(). When dealing with uploaded files, you should always use it (and its cousin move_uploaded_file()) for security reasons.
You can try this:
if($_FILES['myfilename']['size'] > 0 ) {
}
else{
echo 'File is not uploaded . . .';
}
You can use empty to check if a variable is blank or not but Pekka's solution is best in this way
if (empty($_FILES["myfilename"]["name"]))
If you are checking that if a variable is set you can use isset function
The best way, assuming you're using a recent PHP (4.2+), is to check that:
$_FILE['myfilename']['error'] === UPLOAD_ERR_OK
If this is true the upload worked, you can see the list of other possible values here
Try this:
if($_FILES["uploadImg"]['name'][0] != ''){
//echo 'file attached';
}else{
//echo 'no file attached';
}
This works for me...