I m fairly new to PHP, Currently working on picture upload function, I have form where you can upload a picture, picture is not necessary to upload now the problem is code below won't let submit the form without a picture here is my code
$photoCount = count($_FILES['photo']['name'] ); 
if($photoCount > 0)  {
    for($i = 0;$i<$photoCount;$i++) {
        $name = $_FILES['photo']['name'][$i];
        $nameArray = explode('.', $name);
        $fileName = $nameArray[0];
        $fileExt = $nameArray[1];
        $mime = explode('/', $_FILES['photo']['type'][$i]);
        $mimeType = $mime[0];
        $mimeExt = $mime[1];
        $tmpLoc[] = $_FILES['photo']['tmp_name'][$i];
        $fileSize = $_FILES['photo']['size'][$i];
        $uploadName = $name;
        $uploadPath[] = BASEURL.'/admin/productimages/'.$uploadName;
        if ($i != 0) {
            $dbpath .= ',';
        }
        $dbpath .= '/project/admin/productimages/'.$uploadName;
        if($mimeType != 'image') {
            $errors[] .= 'The file must be an image.';
        }
        if(!in_array($fileExt, $allowed)) {
            $errors[] .= 'The file extension must be a png, jpg, jpeg, or gif.';
        }
        if($fileSize > 15000000) {
            $errors[] .= 'The file size must be under 15 megabytes.';
        }
        if ($fileExt != $mimeExt && ($mimeExt == 'jpeg' && $fileExt != 'jpg')) {
            $errors[] = 'File extension does not match the file';
        }
    }
}
Here is var dump of $_FILES
array(1) { ["photo"]=> array(5) { ["name"]=> array(1) { [0]=> string(0) "" } ["type"]=> array(1) { [0]=> string(0) "" } ["tmp_name"]=> array(1) { [0]=> string(0) "" } ["error"]=> array(1) { [0]=> int(4) } ["size"]=> array(1) { [0]=> int(0) } } } 
erros i m getting
Notice: Undefined offset: 1 in C:\xampp\htdocs\project\admin\products.php on line 99
Notice: Undefined offset: 1 in C:\xampp\htdocs\project\admin\products.php on line 102
this is lines 99 and 102
$fileExt = $nameArray[1];
$mimeExt = $mime[1];
 
     
     
     
    