Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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.

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."; 
 } 
  ?>

Can anyone help me..

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
924 views
Welcome To Ask or Share your Answers For Others

1 Answer

I see you are using relative paths, try absolute.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...