Please Help. Uploading Files, I have spent so long trying...
Posted: Sun Oct 01, 2006 10:06 pm
I have no idea why this isnt working. Perhapse it is because I do not have much experience with PHP, I made it through my PHP for teens book, so i know how the language works.. but i cant seem to get this to work...
Its funny everywhere i go, sites all say it is simple, and the code is all so similar between sites for uploading files to the server...
Anyways, i am trying code from this here http://us2.php.net/features.file-upload and it wont work. I get the error "Possible file upload attack!" ... Heres the code i am using exactly, maybe if you find whats wrong with it you can help me.
for the form:
I have literally spent days just trying to make uploads to my server possible... any help is very much appriciated!
Its funny everywhere i go, sites all say it is simple, and the code is all so similar between sites for uploading files to the server...
Anyways, i am trying code from this here http://us2.php.net/features.file-upload and it wont work. I get the error "Possible file upload attack!" ... Heres the code i am using exactly, maybe if you find whats wrong with it you can help me.
for the form:
Code: Select all
<html>
<head>
<title>File Upload Form</title>
</head>
<body>
<!-- The data encoding type, enctype, MUST be specified as below -->
<form enctype="multipart/form-data" action="uploadpro.php" method="POST">
<!-- MAX_FILE_SIZE must precede the file input field -->
<input type="hidden" name="MAX_FILE_SIZE" value="30000" />
<!-- Name of input element determines name in $_FILES array -->
Send this file: <input name="uploadFile" type="file" />
<input type="submit" value="Send File" />
</form>
</body>
</html>Code: Select all
<?php
$uploaddir = '/upload';
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
echo '<pre>';
if (move_uploaded_file($_FILES['uploadFile']['tmp_name'], $uploadfile)) {
echo "File is valid, and was successfully uploaded.\n";
} else {
echo "Possible file upload attack!\n";
}
echo 'Here is some more debugging info:';
print_r($_FILES);
print "</pre>";
?>