Results 1 to 5 of 5
Thread: move_uploaded_file errors
-
12-19-2004, 06:14 PM #1Newbie
- Join Date
- Apr 2004
- Posts
- 11
move_uploaded_file errors
I'm trying to set up a script for uploading pictures, which worked fine on my home test rig of Windows + Apache + PHP 4.3.3. When I upload to the real server, this is the error I get:
================================================
Warning: move_uploaded_file(<full path to site>/working/images/cars/118.jpg): failed to open stream: Permission denied in <full path to site>/working/admin_vehicle.php on line 85
Warning: move_uploaded_file(): Unable to move '/tmp/phpU1DumQ' to '<full path to site>/working/images/cars/118.jpg' in <full path to site>/working/admin_vehicle.php on line 85
================================================
To correct this I made sure that my root, working, images, and car folders were all set to 0777. Same error. I tried CHMODing the temp file to 0777 before the move, and the same error.
I can upload to the FTP folder just fine (not /tmp).
Here is the server info, which is running Plesk 7:
================================================
Apache-AdvancedExtranetServer/2.0.47 (Mandrake Linux/6.5.92mdk) mod_perl/1.99_09 Perl/v5.8.1 mod_webapp/1.2.0-dev mod_ssl/2.0.47 OpenSSL/0.9.7b PHP/4.3.2 FrontPage/5.0.2.2634
================================================
Any help would be appreciated.
-
12-19-2004, 07:57 PM #2Web Hosting Master
- Join Date
- Mar 2004
- Location
- Los Angeles
- Posts
- 622
Can we have a look at your code? If you are sure the directory permissions are set to be writable, than this can be issued from a misuse of the functions.
-
12-19-2004, 08:05 PM #3VP Of Twinkies
- Join Date
- Jan 2004
- Location
- Toronto, ON
- Posts
- 1,104
did you schmod the admin_vehicle.php to 0777 as-well ?
also, some servers dont like 777 (ensim usually) so also try 755.I specialize in neck beards
https://thatshirt.com
-
12-19-2004, 10:20 PM #4Newbie
- Join Date
- Apr 2004
- Posts
- 11
Here is my code, along with the debugging I've added to it:
================================================
if( is_uploaded_file($_FILES['image']['tmp_name']) )
{
print "CHMODing";
if ( chmod($_FILES['image']['tmp_name'], 0777) )
{
if( move_uploaded_file($_FILES['image']['tmp_name'], "/home/httpd/vhosts/<domain>/httpdocs/working/images/cars/$vehicle->id.jpg") )
{
create_thumbnail($vehicle->id, 200);
}
else
{
$error = new error_box("Image Upload Error", "There was a problem uploading the image.");
}
}
}
else
{
print "CHMOD Failed";
}
================================================
I set the code up so that the move_uploaded_file() won't trigger unless the CHMOD returns true. It seems to, because I never get the 'CHMOD Failed' error.
I tried setting admin_vehicle.php to both 777 and 755 and received the same errors.
-
12-19-2004, 10:33 PM #5Newbie
- Join Date
- Apr 2004
- Posts
- 11
OK, I don't know what I missed the first time I tried this script, but now it works. I blew out all the files, reuploaded, reset permissions, and reloaded the database, and now it works just fine.
I'm sure that it was due to one of the suggestions you guys gave, so thanks