Advertisement
Riju18

no.21_php_file_upload(important)

Apr 29th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.42 KB | None | 0 0
  1. ## at first we have to create a folder where we want to save our file.
  2.  
  3. <!DOCTYPE html>
  4. <html>
  5.   <head>
  6.     <meta charset="utf-8">
  7.     <title>php file upload</title>
  8.     <link rel="stylesheet" href="/css/master.css">
  9.     <style media="screen">
  10.       body
  11.       {
  12.         background: gray;
  13.         color: white;
  14.         font: 20px verdana;
  15.         width: 960px;
  16.         margin: 0 auto;
  17.       }
  18.       h2{color: red; font: 30px arial;}
  19.     </style>
  20.   </head>
  21.   <body>
  22.     <h2>How file is uploaded with php works:</h2>
  23.     <hr>
  24.     <?php
  25.         if (isset($_FILES['image']))               //$_FILES is for php file ;
  26.         {
  27.           $imageClient = $_FILES['image']['name'];      //the file which is taken from client;
  28.           $imageServer = $_FILES['image']['tmp_name'];  //it creats a temporary copy;
  29.           move_uploaded_file($imageServer,"image/".$imageClient);
  30.                       //2nd parameter "image/" denotes teh folder name where we want to save our file;
  31.           echo "<span style='color:yellow;'>File is uploaded successfully<span/>";
  32.                   //if teh file is uploaded successfully it'll print it.
  33.           echo "<br>";
  34.           echo "<br>";
  35.  
  36.         }
  37.      ?>
  38.     <form class="" action="" method="post" enctype="multipart/form-data">
  39.       <input type="file" name="image" value="">
  40.       <input type="submit" name="submit" value="submit">
  41.     </form>
  42.   </body>
  43. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement