Hey guys,
I'm using the following code to upload files to a server and it doesn't seem to be working correctly. You should know that register_globals is deactivated... I'm not sure, but I think that might be preventing this script from working... I was hoping there was something I can do with this to make it work..
Thanks guys, any advice is appreciated.
HTML
PHP
OUTPUT
I'm using the following code to upload files to a server and it doesn't seem to be working correctly. You should know that register_globals is deactivated... I'm not sure, but I think that might be preventing this script from working... I was hoping there was something I can do with this to make it work..
Thanks guys, any advice is appreciated.
HTML
Code:
<form enctype="multipart/form-data" action="upload.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="userfile" type="file" />
<input type="submit" value="Send File" />
</form>
PHP
Code:
<?php
// In PHP versions earlier than 4.1.0, $HTTP_POST_FILES should be used instead
// of $_FILES.
$uploaddir = '/public_html/uploads/';
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
echo '<pre>';
if (move_uploaded_file($_FILES['userfile']['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>";
?>
OUTPUT
Code:
Possible file upload attack!
Here is some more debugging info:Array
(
[userfile] => Array
(
[name] => image.jpg
[type] =>
[tmp_name] =>
[error] => 2
[size] => 0
)
)