Jump to content


Photo

File upload problems


  • Please log in to reply
2 replies to this topic

#1 Yesideez

Yesideez
  • Members
  • PipPipPip
  • Advanced Member
  • 2,334 posts
  • LocationDevon, UK

Posted 14 August 2006 - 10:41 PM

Here's my code:
  if ($_POST['subuploadpic']) {
      if (move_uploaded_file($_FILES['picfilename']['tmp_name'],$targetfile)) {
        $msg="File uploaded";
      } else {
        $msg="File upload failed: $targetfile";
      }
  }
$targetfile is set to "/profiles/zeb/profile.jpg"

If I upload "derek.jpg" it fails. If I set $targetfile to "/profiles/zeb/" it fails. If I leave $targetfile empty it works but uploads the file into the root folder. I've tried setting both folders "profiles" and "zeb" to maximum rights (read+write+exec) and still it fails. I've tried every possible combination of folder names even having $targetfile set to "a.jpg" and it will upload derek.jpg into the root folder as a.jpg but I just cannot get it into that folder located at "/profiles/zeb/"

Can anyone see where I'm going wrong? This is the error message I get:
Warning: move_uploaded_file(/profiles/zeb/profile.jpg): failed to open stream: No such file or directory in /home/randgigs/public_html/profile.php on line 39

Warning: move_uploaded_file(): Unable to move '/tmp/phpLsVGHr' to '/profiles/zeb/profile.jpg' in /home/randgigs/public_html/profile.php on line 39

Not a pro just an enthusiast :)

if (empty($coffee)) {$coffee=new coffee();}

Please surround any code using the CODE tags - I rarely look at anything without them

#2 Yesideez

Yesideez
  • Members
  • PipPipPip
  • Advanced Member
  • 2,334 posts
  • LocationDevon, UK

Posted 14 August 2006 - 10:44 PM

I fixed it by removing the first "/" in $targetfile - weird!!!

Only problem is: the folder "zeb" keeps resetting back to chmod(read+exec) - any idea why?
Not a pro just an enthusiast :)

if (empty($coffee)) {$coffee=new coffee();}

Please surround any code using the CODE tags - I rarely look at anything without them

#3 Yesideez

Yesideez
  • Members
  • PipPipPip
  • Advanced Member
  • 2,334 posts
  • LocationDevon, UK

Posted 15 August 2006 - 07:04 AM

Hi guys, I'm still in need of help here if anyone can help...

When users register on my site (they're limited to only a-z characters) they have a folder made in a "profiles" folder which is their username. All their profile images are uploaded here.

When viewing their profile even if logged in I keep getting a 403 (Forbidden) and can't figure out why - anyone have any ideas?
Not a pro just an enthusiast :)

if (empty($coffee)) {$coffee=new coffee();}

Please surround any code using the CODE tags - I rarely look at anything without them




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users