vylan1234 posted on 2010-02-19 00:05:19 #
I have a working upload form and the files show in the directory list and indicates that it is uploaded. But, I thought the actual file would be visible through an FTP client in the directory specified. I have a directory named /upload/ and the files are not getting placed there. I have also made a /upload/ directory in the (/upload_test_ds/) directory.
http://www.inprintz.com/upload_test_ds/upload_demo.php
$folder = $_SERVER['DOCUMENT_ROOT']."/upload/";
$my_upload->upload_dir = $_SERVER['DOCUMENT_ROOT']."/upload/"; // "upload" is the folder for the uploaded files (you have to create this folder)
Here is an error from the log file.
[18-Feb-2010 18:52:18] PHP Warning: opendir(/home/inprintz/public_html/home/inprintz/public_html/) [function.opendir]: failed to open dir: No such file or directory in /home/inprintz/public_html/upload_test_ds/upload_demo.php on line 6
The most popular forum posts:
Comments / discussions
vylan1234 posted on 2010-02-19 00:58:04 #
After researching it appears that the PHP required is something along the following. It looks like the script I'm using uses a temp directory and it is deleted once done with the page. I need the file to be moved to the upload directory. But I'm not sure how to modify the script you offer.
if (file_exists("upload/" . $_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"] . " already exists. ";
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"],
"upload/" . $_FILES["file"]["name"]);
echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
}
}
}
else
{
echo "Invalid file";
}
Olaf posted on 2010-02-19 08:36:24 #
does your upload directory exists? do you checked the permissions for writing?
vylan1234 posted on 2010-02-19 18:02:06 #
Yes, the upload directory exists as stated. And the permissions are set for 755.
"I have a directory named /upload/ and the files are not getting placed there. "
Does the script save the file in the designated directory by default or does it get removed after the script ends? That is what is confusing to me.
Olaf posted on 2010-02-19 18:42:16 #
Just tried your demo and I don't see any error. If you upload a file with php the data is written to a "tmp" directory and after the upload is ready the file is copied to your upload directory.
The data in that "tmp" directory is removed in this moment.
do you use the demo file without modifications?
EDIT: it's possible that the document root variable isn't good on your server...