1//This is the minimal code for an image upload for first time learners
2//html portion
3<!DOCTYPE html>
4<html>
5<head>
6 <title>ImageUpload</title>
7</head>
8<body>
9 <form action="upload.php" method="post" enctype="multipart/form-data">
10 <label>Username</label>
11 <input type="text" name="username">
12 <br>
13 <label>UploadImage</label>
14 <input type="file" name='myfile'>
15 <br/>
16 <input type="submit" value="upload">
17 </form>
18</body>
19</html>
20
21 //php portion
22 <?php
23 $user=$_POST['username'];
24 $image=$_FILES['myfile'];
25 echo "Hello $user <br/>";
26 echo "File Name<b>::</b> ".$image['name'];
27
28 move_uploaded_file($image['tmp_name'],"photos/".$image['name']);
29 //here the "photos" folder is in same folder as the upload.php,
30 //otherwise complete url has to be mentioned
31 ?>