move_uploaded_file():无法移动' D:\ xampp \ tmp \ phpB89.tmp'到' image / pg26_tag_c1102735_1474_17.jpg

时间:2017-05-17 01:41:22

标签: php

我在将图像上传到Xampp服务器时遇到2个错误。我第一次尝试就好了,但在那之后我正面临

move_uploaded_file():无法移动' D:\ xampp \ tmp \ phpB89.tmp'到' image / pg26_tag_c1102735_1474_17.jpg

move_uploaded_file(image / pg26_tag_c1102735_1474_17.jpg):无法打开流:D中没有此类文件或目录

但我上传的图片已插入Xampp,但为什么我仍然会遇到这些错误?

<?php

$msg ="";

if(isset($_POST['upload']))
{
$target = "image/" .basename($_FILES['image']['name']);

$db = mysqli_connect("localhost","root","","agentsdb");

$image = $_FILES['image']['name'];

$sql = "INSERT INTO images_tbl(image) VALUES ('$image')";
mysqli_query ($db,$sql);

if (move_uploaded_file($_FILES['image']['tmp_name'], $target))
{
$msg = "image uploaded successfully, pls go back to login page";
}else{
$msg = "There is a problem";
}
}
?>

<form action="imageform.php" enctype="multipart/form-data" method="post">


<table style="border-collapse: collapse; font: 12px Tahoma;" border="1" 
cellspacing="5" cellpadding="5">
<tbody><tr>

<td>
<input name="image" type="file"> <input type ="submit" name ="upload" value 
= "upload">
</td>
</tr>

<tr>
<td>

</td>
</tr>

</tbody></table>

<?php
echo $msg;
?>
</form>

1 个答案:

答案 0 :(得分:-1)

您有此错误,因为目标目录不存在且 public String toString() { String result = ""; if (head == null) return manyNodes + ""; else{//add here cursor = head; while(cursor.getLink() != null){ cursor = cursor.getLink(); result += cursor.getLink() + ", "; } return "List: " + result; }//and here } 无法移动文件。

您需要手动或以编程方式在您的php文件目录中创建名为move_uploaded_file()的目录

image