I want to know how to upload one image to 2 different folders. Let me give you an example:
I want to upload 1 image. When I upload the image the system will resize the image to 2 different resolutions, portrait with resolution 400x400 and landscape with resolution 1200x1200. After the resizing, the resized image with resolution 400x400 will be stored in folder portrait and the other image will be stored in folder landscape. I'm still confused how to the make that logic.
<?php
//This is the directory where images will be saved
$target = "uploads/potrait/";
$target = $target . basename( $_FILES['photo']['name']);
$target2="uploads/landscape/";
$target2 = $target2 . basename( $_FILES['photo']['name']);
//This gets all the other information from the form
$test=$_POST['test'];
$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 ('$test', '$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, upload failed.";
}
?>