Page 1 of 1

File upload to multiple dirs

Posted: Tue Jun 19, 2007 4:40 am
by mikeeeeeeey
Hi guys,

Just having a bit of a problem uploading two files (from one form) to two different folders on the server. I can get this working on my local testing server but not online? Online, only the 'release' uploads so far...

Here's my code:

Code: Select all

chdir($_SERVER['DOCUMENT_ROOT'] . "/newsletter/");

if(move_uploaded_file($_FILES['release']['tmp_name'], "releases/$release")){
  chdir($_SERVER['DOCUMENT_ROOT'] . "/newsletter/");
  move_uploaded_file($_FILES['image']['tmp_name'], "images/headers/$image")
    or die("Image upload failed...");
}else{
  echo "Release upload failed";
}
I didn't have to use the chdir() locally, but there's other scripts online which deal with uploads, and I've found myself having to use chdir() before I attempt to upload anything.

Any help much appreciated, thanks in advance!

Posted: Tue Jun 19, 2007 4:48 am
by Gente
Try following

Code: Select all

$UploadDir = $_SERVER['DOCUMENT_ROOT'] . "/newsletter/";
if(move_uploaded_file($_FILES['release']['tmp_name'], $UploadDir."releases/$release")){
  move_uploaded_file($_FILES['image']['tmp_name'], $UploadDir."images/headers/$image")
    or die("Image upload failed...");
}else{
  echo "Release upload failed";
}

Posted: Tue Jun 19, 2007 4:58 am
by mikeeeeeeey
thanks for your reply Gente, but it's failing at the very first hurdle, won't even upload the release...

very weird!

Posted: Tue Jun 19, 2007 5:13 am
by Gente
Have you checked the permissions of the folder?

Posted: Tue Jun 19, 2007 5:35 am
by mikeeeeeeey
FFS!!!!!

every single time! I should have my own forum on here called 'When Mikey forgets to chmod all the folders he potentially works in'.

Gente, like every other member (theres a few) that's breathed the words...
Have you checked the permissions of the folder?
I thank you for pointing this out.

I'm now off to get a tattoo saying '777 Everything' on my hand.