aaron_mason
03-17-2008, 04:27 AM
Hello. I have the following html page:
<form action="fileupload.php" method="post" enctype="multipart/form-data">
<p>
<label>Select image to upload : </label>
<input type="file" name="upload" />
</p>
<p>
<input type="hidden" name="MAX_FILE_SIZE" value="25000" />
<input type="submit" value="Submit" />
</p>
</form>
and the following php file (fileupload.php):
<?
if(move_uploaded_file($_FILES['upload']['tmp_name'], "/uploads/" . $_FILES['upload'] ['name'])){
print "<p>The file has been successfully uploaded</p>";
}
else{
switch ($_FILES['upload'] ['error']){
case 1:
print '<p> The file is bigger than this PHP installation allows</p>';
break;
case 2:
print '<p> The file is bigger than this form allows</p>';
break;
case 3:
print '<p> Only part of the file was uploaded</p>';
break;
case 4:
print '<p> No file was uploaded</p>';
break;
}
}
?>
But I get this error:
Warning: move_uploaded_file(/uploads/test.jpg) [function.move-uploaded-file]: failed to open stream: No such file or directory in /home/domain/public_html/fileupload.php on line 2
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/var/tmp/phpVKMa8f' to '/uploads/test.jpg' in /home/domain/public_html/fileupload.php on line 2
Do I need to set appropriate permissions so that users can add files to a directory? Has anyone done this before with hostmonster? What needs correcting?
Please help!
Thanks
<form action="fileupload.php" method="post" enctype="multipart/form-data">
<p>
<label>Select image to upload : </label>
<input type="file" name="upload" />
</p>
<p>
<input type="hidden" name="MAX_FILE_SIZE" value="25000" />
<input type="submit" value="Submit" />
</p>
</form>
and the following php file (fileupload.php):
<?
if(move_uploaded_file($_FILES['upload']['tmp_name'], "/uploads/" . $_FILES['upload'] ['name'])){
print "<p>The file has been successfully uploaded</p>";
}
else{
switch ($_FILES['upload'] ['error']){
case 1:
print '<p> The file is bigger than this PHP installation allows</p>';
break;
case 2:
print '<p> The file is bigger than this form allows</p>';
break;
case 3:
print '<p> Only part of the file was uploaded</p>';
break;
case 4:
print '<p> No file was uploaded</p>';
break;
}
}
?>
But I get this error:
Warning: move_uploaded_file(/uploads/test.jpg) [function.move-uploaded-file]: failed to open stream: No such file or directory in /home/domain/public_html/fileupload.php on line 2
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/var/tmp/phpVKMa8f' to '/uploads/test.jpg' in /home/domain/public_html/fileupload.php on line 2
Do I need to set appropriate permissions so that users can add files to a directory? Has anyone done this before with hostmonster? What needs correcting?
Please help!
Thanks