Forum Moderators: coopster

Message Too Old, No Replies

File Upload Problem (Cannot Create Dir)

Think this is a 'gotcha' with file uploads and PHP

         

Nick_W

12:53 pm on Jun 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Okay, I just know this is going to end in my embarrasment ;)

I chmod -R 777 this dir /var/www/html/site.com/images/

I'm getting this PHP error:

Warning: Unable to create '/var/www/html/site.com/images/': Is a directory in blah

From this code snippet:


if(is_uploaded_file($_FILES['formbigpic']['tmp_name'])) {
$uploaddir="/var/www/html/site.com/images/";
$file2write=$uploaddir.$_FILES['name'];
copy($_FILES['formbigpic']['tmp_name'], $file2write);
print("success!");
exit;
}

Anyone see the 'gotcha'? I've checked the 'common pitfalls' etc in the manual and cannot work out why it does this?

Many thanks!

Nick

Edited cos I was BAD and dropped my url accidently. Sorry Jatar!

[edited by: Nick_W at 1:13 pm (utc) on June 13, 2003]

Birdman

1:08 pm on Jun 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I think I see the error.

$file2write=$uploaddir.$_FILES['name'];

should be

$file2write=$uploaddir.$_FILES['formbigpic']['name'];

Birdman

Nick_W

3:37 pm on Jun 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Ooooh! I hope that's it, sure looks like it ;)

Thanks!

Nick