I want to check if user has uploaded an image using the form.
I have tried:
if (empty($_FILES['txtImage'])) {
$msg = 'Opss, you forgot the image.';
}
I want to check if user has uploaded an image using the form.
I have tried:
if (empty($_FILES['txtImage'])) {
$msg = 'Opss, you forgot the image.';
}
Since PHP 4.2.0, PHP returns an appropriate error code along with the file array.
So,
<?php
if ($_FILES['txtImage']['error'] === UPLOAD_ERR_NO_FILE) {
$msg .= "Opss, you forgot the image.<br>";
}
?>
http://www.php.net/is_uploaded_file
if(!file_exists($_FILES['myfile']['tmp_name']) || !is_uploaded_file($_FILES['myfile']['tmp_name'])) {
echo 'No upload';
}
And additionally, you can check with getimagesize(), If it returns FALSE it is not an image