Page 1 of 1

Troubleshooting file uploading

Posted: Tue Mar 04, 2008 11:36 am
by Rhythmdvl
I had to move a database from one host/domain to another. Almost everything seems to work right, except for a file upload bit.

What is supposed to happen:
A visitor can submit a document for review. After hitting submit, an email notification is sent to the admin, and a record is created in the database (e.g., document name). The admin Review Submissions page shows the document name and other information (i.e., it pulls information from the database), and links to the document. The page gives the admin an opportunity to accept or reject the document. If the admin rejects, the record is deleted from the database. If the admin accepts, the publicly-viewable page will display the file name and link to the document.

Post move, all of the information is correct (filename, new admin e-mail address, database information, file location), and the pages seem to work fine.

HOWEVER:
The $#@%# file never makes it to the directory! Whereas the link shows the right location, and everything else looks ok, the target directory is empty and returns a 404 when clicked.

I’m a very VERY new/amateur PHP user, and this is very tangential to what I normally do. But I am not a complete idiot (blithering, possibly, but not complete), and have some sense of what’s going on.

Here is what I think is the relevant code. There seems to be several globals (I hope that’s what they’re called), but am not sure if it’s taking variables from another page (I couldn’t find instances of other terms, but that doesn’t mean I looked in all the right places). Could someone take a look at it and give me some direction as to how to change the save location? Could you let me know if this has nothing to do with the problem?

Code: Select all

 
if ($_FILES['Filedata']['name']) {
    $uploadDir = $server_dir . "profiles/country/files";
    $uploadFile = $uploadDir . basename($_FILES['Filedata']['name']);
    move_uploaded_file($_FILES['Filedata']['tmp_name'], $uploadFile);   
 
This is from the included file:

Code: Select all

 
$server = "http://www.domain.net/";
$server_dir = "/public_html";
 
The above all works fine when run on the original server, so I’m fairly certain I didn’t inherit a problem. I just want the files to be put to “../files” in the same directory.

Thanks for any insight or suggestions! (oh, and please forgive me if I've posted to the wrong forum or the answer is blindingly obvious. I've searched high and low, but still don't know what's going wrong.)

Rhythm

Re: Troubleshooting file uploading

Posted: Tue Mar 04, 2008 12:06 pm
by Benjamin
Does the folder have write permissions?

Re: Troubleshooting file uploading

Posted: Tue Mar 04, 2008 12:11 pm
by Rhythmdvl
I believe so. I created another database on the new server, with an add file ability, and it runs without a problem.

I also called the hosting company to ask, and though their tech support didn't fill me with the greatest confidence, they did say that all pages running on the server should have admin permissions by default.

If it makes a difference, the other code I'm working with is:

move_uploaded_file($_FILES['document']['tmp_name'], "../search/documents/$file");

where

$file = $_FILES['document']['name'];

Re: Troubleshooting file uploading

Posted: Tue Mar 04, 2008 12:38 pm
by Benjamin
Have you checked the error log?

Re: Troubleshooting file uploading

Posted: Tue Mar 04, 2008 12:47 pm
by Rhythmdvl
The error logs are filled with:

Code: Select all

 
[03-Mar-2008 10:31:52] PHP Warning: move_uploaded_file(/public_htmlprofiles/country/files/1995.pdf) [<a href='function.move-uploaded-file'>function.move-uploaded-file</a>]: failed to open stream: No such file or directory in /home/adaptati/public_html/profiles/country/transfer.php on line 7

The 1995.pdf is a testing document.

Re: Troubleshooting file uploading

Posted: Tue Mar 04, 2008 2:51 pm
by kryles
move_uploaded_file(/public_htmlprofiles/country/files/1995.pdf

looks like you are missing a slash after public_html

Code: Select all

 
 
$uploadDir = $server_dir . "/profiles/country/files";
 
 
maybe that will help