Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## at first we have to create a folder where we want to save our file.
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>php file upload</title>
- <link rel="stylesheet" href="/css/master.css">
- <style media="screen">
- body
- {
- background: gray;
- color: white;
- font: 20px verdana;
- width: 960px;
- margin: 0 auto;
- }
- h2{color: red; font: 30px arial;}
- </style>
- </head>
- <body>
- <h2>How file is uploaded with php works:</h2>
- <hr>
- <?php
- if (isset($_FILES['image'])) //$_FILES is for php file ;
- {
- $imageClient = $_FILES['image']['name']; //the file which is taken from client;
- $imageServer = $_FILES['image']['tmp_name']; //it creats a temporary copy;
- move_uploaded_file($imageServer,"image/".$imageClient);
- //2nd parameter "image/" denotes teh folder name where we want to save our file;
- echo "<span style='color:yellow;'>File is uploaded successfully<span/>";
- //if teh file is uploaded successfully it'll print it.
- echo "<br>";
- echo "<br>";
- }
- ?>
- <form class="" action="" method="post" enctype="multipart/form-data">
- <input type="file" name="image" value="">
- <input type="submit" name="submit" value="submit">
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement