Troubleshooting file uploading
Posted: Tue Mar 04, 2008 11:36 am
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?
This is from the included file:
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
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);
Code: Select all
$server = "http://www.domain.net/";
$server_dir = "/public_html";
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