file upload problem

file upload problem

Posted by: leslie
Posted on: 2005-04-10 12:15:00

I've been searching both the forums and kbase, and still haven't found a solution to the problem I'm having. I'm working on a php/mysql site that I did not originally code, and it was recently moved to Dreamhost from another hosting company, and even though none of the code in the pages in question have changed, the image upload is now not working on Dreamhost.

I've been banging my head against the wall trying to find the exact problem, and none of the solutions to the same problem posted in this forum are applicable to my situation.

The page is in an protected admin area on my client's site, but basically the deal is that a entry is added in the section, that also includes a photo. The photo is uploaded to a temp directory, renamed and moved to another directory, while the entry is written to the db. The entry is writing to the db, but I get this error message everytime regarding the image upload:
Warning: copy(/home/litwin/jenniferlitwin.com/tmp/phpV8LOOl): failed to open stream: No such file or directory in /home/.ogies/
litwin/jenniferlitwin.com/admin/scripts/admin_press.php on line 120

The path to the temp directory is correct and both the temp directory and the final directory where the images are moved to are chmoded to 755. Can someone take a peek at the following code and tell me what I'm obviously overlooking?

Any help would be greatly appreciated. Thanks.

Re: file upload problem

Posted by: decswxaqz
Posted on: 2005-04-10 12:51:00

Line 16

$tmp_upload_path = "/home/litwin/jenniferlitwin.com/tmp/";

You should just be able to put "".... When I've used script I haven't needed to put any directory. I just use $_FILES['upload']['tmp_name'] instead of full directory.

Re: file upload problem

Posted by: leslie
Posted on: 2005-04-10 18:53:00

Thanks for the help, decswxaqz, but after changing it, I'm still getting the same error message and the image isn't being uploaded at all.

Any other ideas about what could be causing the problem?

Thanks.

Re: file upload problem

Posted by: decswxaqz
Posted on: 2005-04-11 00:21:00

Just noticed you/script is using copy. You should be using move_uploaded_file
This is the script I use

if(is_uploaded_file($_FILES['tmp_upload']['tmp_name'])){
if(!move_uploaded_file($_FILES['tmp_upload']['tmp_name'], $base_dir . $_FILES['tmp_upload']['name'])){
$file_upload = FALSE;
echo "<strong>File not uploaded</strong><p></p>";
}
else{
$file_upload = TRUE;
echo "<strong>File uploaded!</strong><p></p>";
}
}

Try chaning line 116 (copy line) to

if (!move_uploaded_file($_FILES['userfile1']['tmp_name'], $final_full_path1)) {

Re: file upload problem

Posted by: leslie
Posted on: 2005-04-11 07:25:00

Changing that line did the trick. Thank you so much for your help! You rock m/
Edited by leslie on 04/11/05 11:34 AM (server time).

Re: file upload problem

Posted by: decswxaqz
Posted on: 2005-04-11 07:37:00

^__^; aww shucks :)
Glad it's working.

Tags: image uploadtemp directoryfile uploaddreamhostphp mysqlphotoobviouslyadmin areahosting companytmpopen streamerror messagepeekuploadedappreciated