如何修复在PHP中上传文件的未定义索引错误

时间:2019-04-15 07:41:16

标签: javascript php

尝试上传文件后出现此错误。

注意:未定义的索引:第20行的C:\ xampp \ htdocs \ lamis \ staff \ title.php中的compfile

尝试上传文件后出现此错误。其他详细记录也很好。

if(isset($_POST['submit'])) {
    $titleNo = $_POST['titleNo'];
    $area = $_POST['area'];
    $map = $_POST['map'];    
    $coord = $_POST['coord'];
    $name = $_POST['name'];    
    $compfile = $_FILES["compfile"]["name"];    
    $ret = mysqli_query($con, "select titleNo from pic where titleNo='$titleNo'");

    $result = mysqli_fetch_array($ret);

    if($result > 0) {
        $_SESSION['msg'] = "Sorry the Records already exists !!";
    } else {
        move_uploaded_file($_FILES["compfile"]
["tmp_name"],"compdocs/".$_FILES["compfile"]["name"]);

        $sql = mysqli_query($con,"insert into pic(titleNo,area,map,coord,name,cFile) values('$titleNo','$area','$map','$coord','$name','$compfile')");

文件标签

<input type="file" name="compfile" class="form-control" value="">

0 个答案:

没有答案