A simple file upload code in php

<?php

if (isset($_POST['submit'])){

$file_name = $_FILES['fileToUpload']['name'];
$file_type = $_FILES["fileToUpload"]["type"];
$tmp_path = $_FILES["fileToUpload"]["tmp_name"];
$path = 'uploads/'.$file_name;
 
    move_uploaded_file($tmp_path, $path);

}

?>


<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> File Upload </title>
</head>
<body align = "center">
<h1>File Upload</h1>
<form method="POST" action="" enctype="multipart/form-data">
<LABEL> Upload Your Image Here:</LABEL>
<br>
<input type="File" name="fileToUpload">
<br>
<input type="submit" name="submit" value="Upload">
</form>
</body>
</html>

Share it in your network:

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

small_c_popup.png

Congratulations!

You have successfully subscribed to my email list. Now you will be recieving latest wordpress tips and tricks directly in your mail box.

Don’t worry! I won’t spam you