I want to upload the same image to 2 different folders within my images folder, but it seems that after I use move_uploaded_file(), I can no longer reference that image from the temp folder again. This is my guess!
Below is what I am coding.
The image does indeed make it to the first folder, but not the second. And also, I am renaming the image with a random number + the extension. Not that it is important, but just in case someone asks what I'm doing.
<?
$fileName = $_FILES['NEWFILE1']['name'];
$tmpName = $_FILES['NEWFILE1']['tmp_name'];
$fileSize = $_FILES['NEWFILE1']['size'];
$fileType = $_FILES['NEWFILE1']['type'];
$ext = findexts($_FILES['NEWFILE1']['name']) ;
$random = rand() . "."; // make a random file name
$uploadDir1 = '/images/1/';
$uploadDir2 = '/images/2/';
$target1 = $uploadDir1 .'1_'. $random .$ext; // this is the path to the new image
$target2 = $uploadDir2 .'1_'. $random .$ext; // this is the path to the new image
$UPLOADresult1 = move_uploaded_file($tmpName, $target1);
$UPLOADresult2 = move_uploaded_file($tmpName, $target2);
?>
Anyone got an idea of how I can upload 1 image to 2 separate folders? Or perhaps see what I can change in my code to allow for it?