A
Anonymous
Guest
Hi
I am trying to upload a file from user to the webserver.
The form is updated but no file is uploaded.
I am using PHP 5 and apache 2
I am trying to upload a file from user to the webserver.
The form is updated but no file is uploaded.
I am using PHP 5 and apache 2
Code:
<HTML>
<HEAD>
<TITLE>Upload File</TITLE>
</HEAD>
<BODY>
<?php
$submit = $_POST[submit];
if($submit)
{
$uploaddir = '/EclipseWorkspace/LPCL101/files/';
$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>";
}
else if(!$submit)
{
?>
<h1>Upload File</h1>
<form enctype="multipart/form-data" action="upload_file.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="30000" >
Send this file: <input name="userfile" type="file" >
<input type="Submit" name="submit" value="Send File" >
</form>
<?php
}
?>
</BODY>
</HTML>