Hello all, my first post here. I just started using PHP and I am trying to create an easy PHP upload script to let users of my web site uploads pictures for the phpBB forum that I recently set up. I read up on the manual, my PHP book, and numerous PHP resources, but I can't figure out this error that I get. Here the very simple PHP Upload script that I found and used:
<?php
// basic php file upload example
// [url]http://php.snippetdb.com[/url]
if ($_POST['upload']){ //process uploaded file
$uploadDir = '../uploads/'; //file upload path
$uploadFile = $uploadDir . $_FILES['uploadfile']['name'];
echo "<pre>";
if (move_uploaded_file($_FILES['uploadfile']['tmp_name'], $uploadFile) )
{
echo "File is valid, and was successfully uploaded. ";
echo "Here's some more debugging info:\n";
}
else
{
echo "ERROR! Here's some debugging info:\n";
echo "remember to check valid path, max filesize\n";
}
var_dump($_FILES);
echo "</pre>";
} else { //display upload form
?>
<form enctype="multipart/form-data" action="<?php echo $_SERVER['SCRIPT_NAME']?>" method="post"> <!-- do i need to change this to upload.php? -->
<input type="hidden" name="MAX_FILE_SIZE" value="1024000">
<br>
<input name="uploadfile" type="file">
<br>
<input name= "upload" type="submit" value="Upload File">
</form>
<?php
}
?>
So I set up a folder that isn't accesible to the web that's chmodded to 777. Whenever I try to upload files to my /upload directory, I get this error:
Warning: Unexpected character in input: ' ' (ASCII=12) state=1 in /usr/local/dh/cgi-system/php.cgi on line 2987
Parse error: parse error, unexpected T_STRING in /usr/local/dh/cgi-system/php.cgi on line 2987
Btw, I'm using Dreamhost if that means anything. Thanks.