, 서버에 이미지를 업로드하려고합니다. 서버에 'images'폴더가 있습니다. 'ok'버튼을 클릭 할 때마다 ... "파일 업로드에 문제가 있습니다"라는 오류 메시지가 나타납니다. 내 코드의 문제는 어디에 있습니까?다음 코드에서 PHP를 사용하여 이미지를 서버에 업로드
html -----------------------------------------
<form method="post" action="newproduct.php" enctype="multipart/form-data">
Item Image:<input type="file" name= "photo" size="40" />
Description:<textarea name="description" cols="40" rows="1"></textarea>
<input name="submit" type="submit" value = "Submit" />
</form>
php-------------------------------------------------------
$target = "images/";
$target = $target . basename($_FILES['photo']['name']);
$pic=($_FILES['photo']['name']);
$description =$_POST["description"];
//checking for empty values
if (empty($pic) || empty($description))
{
echo "Please enter all field values.";
}
else
{
//Connecting to database server
//Connecting to database
//INSERT Query
$SQLstring = "INSERT INTO items VALUES(null,'$pic' ,'$description')";
$QueryResult = @mysqli_query($DBConnect, $SQLstring)
or die ("<p> Unable to execute the query. </p>".
"<p> Error code " . mysqli_errno($DBConnect) . ":" . mysqli_error($DBConnect))."</p>";
if(move_uploaded_file($_FILES['photo']['name'], $target))
{
echo "The file has been added to the directory";
}
else
{
echo "Sorry, there was a problem uploading your file.";
}
mysqli_close($DBConnect);
}
?>
그것은 않을 것입니다
파일이 업로드되었거나되지 않았습니까? – Dev
@dev 예 폴더 'images'가 이미 존재합니다. – Ayman