将图像上传到服务器中的两个不同文件夹
在我的 Wamp 服务器中,我有文件夹调用自拍.upload.php 位于此文件夹中.当我上传图像时,此图像保存在自拍文件夹内的上传"文件夹中.同时,我的 wamp 服务器中有另一个名为admin"的文件夹.它还包含文件夹调用上传"
In my Wamp server I have folder call selfie. upload.php located within this folder. When I upload an image this image save inside the 'uploads' folder which is inside the selfie folder. At the same time I have another folder call 'admin' inside my wamp server. It also contain folder call 'uploads'
我想要的是将相同的图像保存到两个上传"文件夹中.我使用了复制".但它不起作用.
What I want is save same image to both 'uploads' folders. I used 'copy'. But it's not work.
这是我的upload.php,它位于'selfie'文件夹内.
Here is my upload.php which is located inside the 'selfie' folder.
<?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.";
}
?>
谁能帮帮我..
我看到您使用的是相对路径,请尝试使用绝对路径.
I see you are using relative paths, try absolute.