i tried a code for file upload(
http://php.snippetdb.com/view.php?ID=69) but i didnt get it to work. here is my code in filesend.php:
Code:
<?php
// basic php file upload example
// http://php.snippetdb.com
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">
<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
}
?>
i made the directory named uploads and i chmod 777 both the file and the directory. It gives me a error message:Warning: move_uploaded_file(): SAFE MODE Restriction in effect. The script whose uid is 26946 is not allowed to access / owned by uid 0 in /home/865095/public_html/filesend.php on line 9
ERROR! Here's some debugging info:
remember to check valid path, max filesize
array(1) {
["uploadfile"]=>
array(5) {
["name"]=>
string(9) "test.txt"
["type"]=>
string(10) "text/plain"
["tmp_name"]=>
string(14) "/tmp/phpnbw4Dy"
["error"]=>
int(0)
["size"]=>
int(5)
}
}
What's wrong with it?Any ideas?