Upload a file to the Server

Upload a file to the Server using|PHP

welcome back to shortlearner.com , in our previous post we learn how to Convert words to numbers in PHP. in this post we will see how to Upload a file to the Server with the help of PHP.
Let’s go through the overview of this program before starting the tutorial. So we will first create a file with the name index.php, in this file we are creating a responsive form by using bootstrap classes and taking a file from user and after submitting the form we will upload it on the server.

Upload a file to the Server

Index.php

<html>
 <head>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css"><!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
 </head> 
 <body> 
<form method="post"   action="index.php" enctype="multipart/form-data">
 Resume : <input type="file" name="f1" class="form-control"> <br>
<input type="submit" value="Upload" class="btn btn-success">
</form> 
</body> 
</html>

Also Read :
PHP Login Script With Remember me.
Unable to create a directory a wordpress error
Change password using javascript, php and mysqli.
Password and Confirm Password Validation Using JavaScript
Check Email is Already Registered in Database using Ajax and JavaScript.
How to hide extension of html and php file.?

after submitting the form we will upload this file on the server using below code.

<?php 
if(is_uploaded_file($_FILES['f1']['tmp_name'])) {  
$fname = $_FILES['f1']['name'];            if(move_uploaded_file($_FILES['f1']['tmp_name'],"uploads/$fname"))
{   
echo "Uploaded successfully";
 } 
else
 {  
echo "Not uploaded";
 }
 } 
?>