I am having problem with this coding, the upload works fine just that, if I didn’t upload any picture it will echo the error, if I upload just one picture it won’t show any error message, now I want to make it if nothing to be uploaded, it won’t echo the error message but I wanted to remain the error message just incase something went wrong I know there is problem. Thanks!
// Upload begins!!
if ($_FILES['ufile']['name'][0] != "")
{
$target_path = "."."/uploads/".$petname."/".$_FILES['ufile']['name'][0];
copy($_FILES['ufile']['tmp_name'][0], $target_path);
$filesize1=$_FILES['ufile']['size'][0];
}
if ($_FILES['ufile']['name'][1] != "")
{
$target_path1 = "."."/uploads/".$petname."/".$_FILES['ufile']['name'][1];
copy($_FILES['ufile']['tmp_name'][1], $target_path1);
$filesize2=$_FILES['ufile']['size'][1];
}
if ($_FILES['ufile']['name'][2] != "")
{
$target_path2 = "."."/uploads/".$petname."/".$_FILES['ufile']['name'][2];
copy($_FILES['ufile']['tmp_name'][2], $target_path2);
$filesize3=$_FILES['ufile']['size'][2];
}
// Check for error!!
if($filesize1 || $filesize2 || $filesize3 != 0)
{
}
// If got error, show message
else
{
echo "<div class='error'>ERROR : There seems to be problem uploading the pictures.</div>";
}
I managed to solved it myself, bottom here is my solution:-