<! DOCTYPE html>
<meta http-equiv= "Content-type" content= "Html/text;charset=utf-8"/>
<body>
<form action= "#" name= "form" method= "POST" enctype= "Multipart/form-data" >
<p>
<input type= "file" Name= "img" value= "choose to upload Files"/>
</p>
<input type= "Submit" value= "Upload"/>
</form>
</body>
<?php
Date_default_timezone_set ("PRC"); Set time zone
if (count ($_files) >0) {
$sort = Array ("Image/jpeg", "image/jpg", "Image/gif", "IMAGE/PDG");
Determine if it is a picture type
if (In_array ($_files[' img '] [' type '], $sort)) {
$IMG = "img"; Gets the location of the uploaded folder
Determine if a folder exists, if there is no creation of a
if (!file_exists ($img)) {
mkdir ("$img", 0700); 0700 Maximum Privileges
}
$time =date ("y_m_d_h_i_s"); Get current time
$file _name = Explode (".", $_files[' img '] [' name ']); $_files[' img ' [' name '] The name of the upload file explode string to interrupt the spin string
$file _name[0]= $time;
$name = Implode (".", $file _name); Implode the array into strings
$img _name = "img/". $name;
if (Move_uploaded_file ($_files[' img '] [' tmp_name '], $img _name)) {//move_uploaded_file Move file
echo "<center>
<p>
<a href= ' img_uploading.php ' > re-upload </a></p></center>;
}else{
echo "Upload failed";
}
}else{
echo "is not a picture type";
}
}
?>