我有这些错误
Warning: move_uploaded_file(Applications/XAMPP/xamppfiles/htdocs/uploadfile/images/Red-Alienware-Wallpaper-HD.jpg): failed to open stream: No such file or directory in /Applications/XAMPP/xamppfiles/htdocs/uploadfile/add.php on line 21
Warning: move_uploaded_file(): Unable to move '/Applications/XAMPP/xamppfiles/temp/phpeidba7' to 'Applications/XAMPP/xamppfiles/htdocs/uploadfile/images/Red-Alienware-Wallpaper-HD.jpg' in /Applications/XAMPP/xamppfiles/htdocs/uploadfile/add.php on line 21
Sorry, there was a problem uploading your file.
这是我上传照片的脚本
<?php
include "configdb.php";
//This is the directory where images will be saved
$target = "Applications/XAMPP/xamppfiles/htdocs/uploadfile/images/";
$target = $target . basename($_FILES['photo']['name']);
//This gets all the other information from the form
$name=$_POST['name'];
$email=$_POST['email'];
$phone=$_POST['phone'];
$pic=($_FILES['photo']['name']);
//echo $pic
// Connects to your Database
//Writes the information to the database
mysql_query("INSERT INTO `employees` VALUES ('$name', '$email', '$phone', '$pic')") ;
//Writes the photo to the server
if(move_uploaded_file($_FILES['photo']['tmp_name'], $target))
{
//Tells you if its all ok
echo "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
echo "Sorry, there was a problem uploading your file.";
}
?>
其他详细信息正在数据库中插入,包含文件名。但图像不会插入到文件目录中。我已经创建了一个名为“images”的文件夹,但仍然无法正常工作。 顺便说一下,我正在使用OSX山狮
我已将代码更改为:
<?php
include "configdb.php";
//This is the directory where images will be saved
$target = "Applications/XAMPP/xamppfiles/htdocs/uploadfile/images/";
$target = $target . basename($_FILES['photo']['name']);
//This gets all the other information from the form
$name=$_POST['name'];
$email=$_POST['email'];
$phone=$_POST['phone'];
$pic=($_FILES['photo']['name']);
//echo $pic
// Connects to your Database
//Writes the information to the database
mysql_query("INSERT INTO `employees` VALUES ('$name', '$email', '$phone', '$pic')") ;
if (file_exists("images/" . $_FILES["photo"]["name"]))
{
echo $_FILES["photo"]["name"] . " already exists. ";
}
else
{
move_uploaded_file($_FILES["photo"]["tmp_name"],
"images/" . $_FILES["photo"]["name"]);
echo "Stored in: " . "images/" . $_FILES["photo"]["name"];
}
?>
现在我收到错误无法打开流:权限被拒绝