In this tutorial we will learn how to files upload on remote server using a HTML form and PHP.

Creating an HTML form to upload the file

The following example will create a simple upload.php form that can be used to upload files.This form is having method attribute set to post and enctype attribute is set to multipart/form-data.

<!DOCTYPE html>
<html lang="en">
  <title>Upload file </title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="">
  <script src=""></script>
  <script src=""></script>
  <script src=""></script>

<div class="container">
  <h2>Upload file</h2>
  <form action="upload_pro.php" method="post" enctype="multipart/form-data">
    <div class="form-group">
      <input type="file" class="form-control" id="img" name="img" accept="image/*">
    <button type="submit" class="btn btn-primary">Submit</button>


Processing the uploaded file

Here's the complete code of our upload_pro.php file.

        $img_name = time().$_FILES['img']['name'];
        $tmp_name = $_FILES['img']['tmp_name'];



After you create img folder.

After execute this example by visiting the following URL in the browser and this URL may be different based on your site.