php - upload images to two different folders in server -
in wamp server have folder call selfie. upload.php located within folder. when upload image image save inside 'uploads' folder inside selfie folder. @ same time have folder call 'admin' inside wamp server. contain folder call 'uploads'
what want save same image both 'uploads' folders. used 'copy'. it's not work.
here upload.php located inside 'selfie' folder.
<?php //this directory images saved $target = "uploads/"; $target = $target . basename( $_files['photo']['name']); $target2="admin/uploads/"; $target2 = $target2 . basename( $_files['photo']['name']); //this gets other information form $cat=$_post['cat']; $desc=$_post['desc']; $pic=($_files['photo']['name']); $loc=$_post['location']; // connects 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 information database mysql_query("insert image_upload (category, description,image ,location) values ('$cat', '$desc','$pic','$loc')"); //writes photo server if(move_uploaded_file($_files['photo']['tmp_name'], $target)) { copy($target, $target2); } else { //gives , error if not echo "sorry, there problem uploading file."; } ?>
can me..
i see using relative paths, try absolute.
Comments
Post a Comment