This will learn you how to upload files on your website Here is the code
<?php
echo "<form action='' method='post'>
<input type='file' name='file'><br/>
<input type='submit' name='submit' value='Upload File'></form>";
if(isset($_POST["submit"])){
$filetm = $_FILES['file']['tmp_name'];
$file = $_FILES['file']['name'];
$dr = "files/";
if(move_uploaded_file($filetm,$dr.$file)){
echo "File uploaded successfully<br/>Thank you for uploading the file";
} }
?>
echo "<form action='' method='post'> <input type='file' name='file'><br/> <input type='submit' name='submit' value='Upload File'></form>";
This will print out the form
if(isset($_POST["submit"])){ $filetm = $_FILES['file']['tmp_name']; $file = $_FILES['file']['name']; $dr = "files/";
If the Upload File button is clicked, it will then put the temporary file in a variable and the file name in a variable and it will put the directory of the file to be uploaded in a variable.
if(move_uploaded_file($filetm,$dr.$file)){ echo "You have uploaded the file successfully<br/>Thank you for uploading the file";
This will upload the file to the server and print a message saying you have uploaded the file successfully.
Thank you for reading my PHP Uploader tutorial Thank you Michael
Comments
Post new comment