Jump to content

Need some help with file upload...


phpnoobie9

Recommended Posts

I'm trying to get image2 to have the same name as the first image but be placed in a different directory. I can get the first image to upload and have the name be md5 randomly, but can't get the second image to upload.

 

//Directory paths
$absolutepath = ABSOLUTE_PATH;
$absolutepath2 = ABSOLUTE_PATH2;
echo "Main 150x150 screenshot path: ".$absolutepath."<br /> Secondary 200x200 screenshot path: ".$absolutepath2;

//Start image upload

//Check for an image
$newname = md5(time()*rand(1,99999).$_FILES['image']['name']);
$newname2 = $newname.'.jpg';
if (move_uploaded_file ($_FILES['image']['tmp_name'], ABSOLUTE_PATH."$newname2")) {
echo '<p>Image uploaded</p>';
} else {
echo '<p>Problem uploading image</p>';
}

//Check for image2
if (move_uploaded_file ($_FILES['image']['tmp_name'], ABSOLUTE_PATH2."$newname2")) {
echo '<p>Image2 uploaded</p>';
} else {
echo '<p>Problem uploading image2</p>';
}

Link to comment
https://forums.phpfreaks.com/topic/99604-need-some-help-with-file-upload/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.