I made a simple upload script so I can upload images from a web based interface on my website. The code for the script is:
<form name="form1" method="post" action="" enctype="multipart/form-data">
<input type="file" name="imagefile">
<input type="submit" name="Submit" value="Submit">
<?
if(isset( $Submit ))
{
//If the Submitbutton was pressed do:
if ($_FILES['imagefile']['type'] == "image/gif"){
copy ($_FILES['imagefile']['tmp_name'], "files/".$_FILES['imagefile']['name'])
or die ("Could not copy");
echo "";
echo "Name: ".$_FILES['imagefile']['name']."";
echo "Size: ".$_FILES['imagefile']['size']."";
echo "Type: ".$_FILES['imagefile']['type']."";
echo "Copy Done....";
}
else
{
echo "";
echo "Could Not Copy, Wrong Filetype (".$_FILES['imagefile']['name'].")";
}
}
?> </form>
The error I am getting is: Warning: copy(files/ela.gif): failed to open stream: Permission denied in /home/josh/public_html/upload.php on line 12
Could not copy
What can I do to get this to work. I made sure that the folder files is actually there and it still does not work. I also tried uploading a non .gif file and the script wont allow it because I made it not allow it, so I know there is something wrong with the function copy.