大家好

时间:2019-03-27 10:39:07

标签: image upload

这是代码

if(!empty($_FILES)){
    var_dump($_FILES);
    $photo = $_FILES['photo'];
    $name = $photo['name'];
    $nameArray =explode('.',$name);
    $fileName = $nameArray[0];
    $fileExt = $nameArray[1];
    $mime = explode('/',$photo['type']);
    $mimeType = $mime[0];
    $mimeExt = $mime[1];
    $tmpLoc = $photo['tmp_name'];
    $fileSize = $photo['size'];
    $allowed = array('png','jpg','jpeg','gif');
    $uploadName = md5(microtime()).'.'.$fileExt;
    $uploadPath = BASEURL. 'images/products/'. $uploadName; //proizvodi proveri
    $dbpath = '/webshop/images/products/'.$uploadName; //?

    if($mimeType != 'image'){
        $errors[]='File must be picture.';
    }
    if (!in_array($fileExt,$allowed)){
        $errors[]= 'File must be in  (*png,*jpg,*jpeg,*gif) formatu.';
    }
    if($fileSize > 150000000 ){
        $errors[]= 'myst be under 25mb.';
    }
    if($fileExt != $mimeExt && ($mimeExt == 'jpeg' && $fileExt != 'jpg' )){
        $errors[]= 'bla bla.';
    }
}

当我插入较大的图像或jpg格式时,会出现错误:

  

注意:未定义的偏移量:1 in C:\ xampp \ htdocs \ webshop \ admin \   第49行的products.php

并且我注意到文件必须是图像???

0 个答案:

没有答案