在我的Wamp服务器中,我有文件夹调用自拍。 upload.php位于此文件夹中。当我上传图片时,此图片会保存在'上传内容中。自拍文件夹里面的文件夹。与此同时,我有另一个文件夹调用' admin'在我的wamp服务器里面。它还包含文件夹调用'上传'
我想要的是将相同的图片同时保存到'上传'文件夹。我使用了' copy'。但它不起作用。
这是我的upload.php,它位于' selfie'文件夹中。
<?php
//This is the directory where images will be saved
$target = "uploads/";
$target = $target . basename( $_FILES['photo']['name']);
$target2="admin/uploads/";
$target2 = $target2 . basename( $_FILES['photo']['name']);
//This gets all the other information from the form
$cat=$_POST['cat'];
$desc=$_POST['desc'];
$pic=($_FILES['photo']['name']);
$loc=$_POST['location'];
// Connects to your Database
mysql_connect("localhost", "root", "") or die(mysql_error()) ;
mysql_select_db("selfie") or die(mysql_error()) ;
$filename = mysql_real_escape_string($_FILES['photo']['name']);
//Writes the information to the database
mysql_query("INSERT INTO image_upload (category, description,image ,location) VALUES ('$cat', '$desc','$pic','$loc')");
//Writes the photo to the server
if(move_uploaded_file($_FILES['photo']['tmp_name'], $target))
{
copy($target, $target2);
}
else {
//Gives and error if its not
echo "Sorry, there was a problem uploading your file.";
}
?>
任何人都可以帮助我..
答案 0 :(得分:1)
我看到你正在使用相对路径,尝试绝对路径。