|
Posted by sean on 12/04/85 11:57
Hi,
I am a complete novice but would liket to have a PHP script which will
upload a file which is pre-defined, without the need for the user to
'Browse' for a file path. For example, the pre-defined file would be
"C:\temp\test.txt", and the script will already know this value
without the user telling it.
I tried filling the textbox with a file path value, but it doesn't
work with the input type "file", only as a "textbox". So I am now
certain that the PHP code is the only way to maybe solve it, and
hoping someone can help me
Here's the 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>
And here's the PHP code:
<?php
$uploaddir = '/home/vhosts/seanlock.275mb.com/uploads/';
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
echo '<pre>';a
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>";
?>
If anyone knows of a simple way of achieving what I'm after, I'd be
really grateful for any help.
Regards,
Sean
Navigation:
[Reply to this message]
|