I want a really simple File Upload script on my site. It will sit in my root directory and I only need it to upload files into the root directory.
So I've created a form with METHOD=POST and ENCTYPE='multipart/form-data'. Then I've created the <INPUT TYPE=FILE NAME=filename> and also placed a submit button on the form.
I tested this part by putting:
echo $_FILES['filename']['name'];
and it is definitely working.
Now I have a choice of using copy() or move_uploaded_file() to get the file from the temporary directory into the root directory.
The problem I have is, how do I tell it what the root directory is? I've tried this:
if (is_uploaded_file($_FILES['filename']['tmp_name'])) {
copy($_FILES['filename']['tmp_name'], $_SERVER['DOCUMENT_ROOT']);}
else {
echo "Problem with File Upload";}
But I get the following error:
Warning: Unable to create '/home': Is a directory in /home/l/u/luminosity/public_html/fileupload.php on line 6
Line 6 is the copy.......
http://luminosity.greater-peterborough.com/fileupload.php
Any ideas?