PHP Uploading Files
upload.html
Code:
<html>
<head>
<title>File Upload Form</title>
</head>
<body>
This form allows you to upload a file to the server.<br>
<form action="upload.php" method="post"><br>
Type (or select) Filename: <input type="file" name="uploadFile">
<input type="submit" value="Upload File">
</form>
</body>
</html>
Save following as
upload.php
Code:
<html>
<head>
<title>Process Uploaded File</title>
</head>
<body>
<?php
move_uploaded_file ($_FILES['uploadFile'] ['tmp_name'],
"./uploads/{$_FILES['uploadFile'] ['name']}")
?>
</body>
</html>
Create a directory "uploads" in current folder.
Note: This script is insecure. Do not upload to public server and keep it there. Anyone can upload files to your web server. For example, they upload a movie or a PHP Shell (hacked tool) or spam mail too and sent mail. There can be lot of abuse if such a script is made available on a public server.
Bookmarks