Reputation: 9
I need to check if the image is NULL on my webpage. Currently i'm only been able to upload .png files on my website.
<img src="uploads/user_pic/<?php echo $first_name.'_'.$last_name.'/'.'profile_pic'.'/'.'profile_pic.'.'png'; ?>" class="img-thumbnail" />
so, I've been trying to do this, but I've run out of idea's on how to check on missing item's.
switch (missingImage) {
case "jpg":
<img src="uploads/user_pic/<?php echo $first_name.'_'.$last_name.'/'.'profile_pic'.'/'.'profile_pic.'.'jpg'; ?>" class="img-thumbnail" />
break;
... so on and so forth
}
Upvotes: 0
Views: 4859
Reputation: 13
Do something like this:
$photoName = $_FILES["photo"]["name"];
Then you check if it is empty:
if(empty($photoName))
{
echo json_ecode(array("message" => "photo required"));
}
Upvotes: 1
Reputation: 732
We check for size and if there are any errors. Replace imageName with how your image field is called.
if ($_FILES['imageName']['size'] == 0 && $_FILES['imageName']['error'] == 0){
//File is empty
}
Upvotes: 0