我已经编写了图片上传文件,它显示错误"未定义的索引:第3行和第34行的C:\ xampp \ htdocs \ Schmgt \ svr \ upload_image.php中的图片;
但我无法在我的代码中找到任何问题。请帮帮我。
HTML表单
<form action="../svr/upload_image.php" method="post" id="form_po" enctype="multipar/form-data">
<div class="row"><br/></div>
<div class="row">
<div class="col-md-2"> </div>
<div class="col-md-4">
<?php
$nic=$_GET['nic'];
?>
<input type="hidden" class="form-control" id="txt_po_number" name="txt_nic" value="<?php echo $nic; ?>" readonly>
</div>
</div>
<br/>
<br/>
<div class="row">
<div class="col-md-4"></div>
<div class="col-md-3">
<div style="border: 1px solid black">
<img src="../img/user.png" width="235px" height="250px">
</div>
</div>
</div>
<div class="row">
<div class="col-md-4"></div>
<div class="col-md-3">
<div style="border: 1px solid black">
<input type="file" name="image" class="form-control"/>
</div>
</div>
</div>
<br/>
<div class="row">
<div class="col-md-1"></div>
<div class="col-md-10">
</div>
</div>
<div class="row">
<div class="col-md-4" style="margin-right: 50px;">
</div>
<div class="col-md-2">
<input type="submit" id="btn-next" name="btn-submit" class="form-control btn-success" value="Finish">
</div>
</div>
<br/>
</form>
PHP文件upload-image.php文件
<?php
include 'connection.php';
$target="../img/". basename($_FILES['image']['name']);
$img=$_FILES['image']['name'];
$text=$_POST['txt_nic'];
var_dump($img);die;
$query1="INSERT INTO image(nic,image)VALUES('$text','$img')";
if(move_uploaded_file($_FILES['image']['tmp_name'], $target)){
} else {
}
?>
答案 0 :(得分:1)
检查表单中的enctype。它应该像enctype =&#34; multipart / form-data&#34;而你也忘了运行查询。