I have a form that allows for 5 images to be uploaded. They will then be renamed and the name will be put in the db. How do I get it not to run if an image is not selected?
I want to be able to skip the process if no image is selected.
$userID="test";
include('library/login.php');
login();
mysql_select_db('test);
if ($photo_1 != 'null')
{
$extension = strrchr($_FILES['photo_1']['name'],'.');
$extension = strtolower($extension);
$photoNumber="_1";
$finalName="$userID$photoNumber";
$save_path = "uploads/";
$target_path = $save_path . basename( $_FILES['photo_1']['name']);
$NewPhotoName = $finalName;
$withExt = $NewPhotoName . $extension;
$filename = $save_path . $NewPhotoName . $extension;
if(move_uploaded_file($_FILES['photo_1']['tmp_name'], $filename)) {
$query = "UPDATE photos SET photo_1='$withExt' WHERE userID='$userID'";
$result = mysql_query($query) or die(mysql_error());
} else{
echo "Error Uploading";
}
}
I am not 100% how images are handled.