아래 코드로 서버의 디렉토리에 그림을 업로드하려고했습니다.업로드 된 파일을 옮길 때 오류가 발생했습니다.
경고 : 인 move_uploaded_file (이미지 /) [function.move 업로드 파일] 그러나, 내가 그것을 실행할 때, 나는이 오류 스트림을 열지 못했습니다 :/홈/a2943534/public_html이있는 디렉토리입니다 줄에 /add.php 24
경고 : 인 move_uploaded_file() [function.move 업로드 파일] :/홈/a2943534/public_html을 /에서 '이미지 /'에 '/ tmp를/php7yEkDe'을 이동할 수 없습니다 add.php on line 24
무엇을 놓치고 있습니까?
<?php
include_once("connect.php");
?>
<?php
//This is the directory where images will be saved
$target = "images/";
$target = $target . basename($_FILES['photo']['title']);
//This gets all the other information from the form
$title=$_POST['title'];
$name=$_POST['name'];
$describe=$_POST['describe'];
$pic=($_FILES['photo']['title']);
$url=$_POST['url'];
$country=$_POST['country'];
$endDate=$_POST['endDate'];
//Writes the information to the database
mysql_query("INSERT INTO `authors` VALUES ('$title', '$name', '$describe', '$pic', '$url', '$country', '$endDate')") ;
//Writes the photo to the server
if(move_uploaded_file($_FILES['photo']['tmp_name'], $target))
{
//Tells you if its all ok
$result = "The file ". basename($_FILES['uploadedfile']['name']). " has been uploaded, and your information has been added to the directory";
}
else {
//Gives and error if its not
$result = "Sorry, there was a problem uploading your file.";
}
?>
<?php
// if the form has been submitted, display result
if (isset($result)) {
echo "<p><strong>$result</strong></p>";
}
?>
'images' 디렉토리가 실제로 존재하는지 확인하십시오. –
또한'images' 디렉토리에 쓰기 권한이 있는지 확인하십시오. – JRSofty
처음에는 위생 처리가 누락되어 임의의 파일 쓰기 취약점이 발생합니다. http://stackoverflow.com/questions/1911382/sanitize-file-path-in-php – Polynomial