First, prepare
1. Upload Control <input type= "file" Name= "img"/>
<tr>
<TD align= "Right" > Avatar </td>
<td>
<input type= "File" Name= "Site_logo" size= ""/>
<a href= ". /theme/default/images/logo.gif "target=" _blank "></a>
</td>
</tr>
2. Form form Add attribute enctype= "Multipart/form-data"
3, processing the page to get uploaded files information
$_files
Second, the operation process
1, first through the error value to determine if there is a choice to upload pictures
if ($_files[' img ' [' error '] = = 0) When no picture is selected, the value of $_files[' img ' [' ERROR '] is equal to zero
2, perform the upload function move_uploaded_file (temporary storage path, set the project storage path)
$name = Time (). rand (111,999);
$path = ' uplpads/'. $name. JPG ';
Move_uploaded_file ($_files[' img '] [' tmp_name '], $path);
Time () timestamp from the wee hours of January 1, 1970 to the number of seconds elapsed from the execution time
Rand (start number, end number) takes the starting number to the random number of the ending number
3, define the variable $path= "";
If the statement in if is not executed when no picture is selected, then there is no $path variable and an error occurs during execution
4. Assign the path of the uploaded image to the $ variable
Create the Uploads folder in admin
5. Add the fields stored in the picture path in the database statement
6, the foreground index.html file to find the location of the graphic, using ' $alt =" image "/> Display image
Upload images of website production