Upload image function:
Get current folder location, upload to current folder
In order to upload after the file name repeatedly caused the overwrite, after uploading the change name: Current time + original file name
Only allow file uploads in GIF, JPEG, BMG, JPG format
<form name= "Frm1" enctype= "Multipart/form-data" action= "" method= "POST" > <input name= "filename" type= "file" style= "border:solid 1px #6ac1e2; width: 200px; border-radius: 5px "/> <input name=" submit " type=" Submit " value=" submitted " style=" background-color: #e28c8e;border-radius: 5px; font-size: 14px; " /></form><?phpif (Isset ($_post[' submit ')) { $dir = dirname (_ _file__); $dir = str_replace ("//", "/", $dir) . "/"; date_default_timezone_set ("PRC"); $date = date ( "Ymdhis"); $filename = $date. $_files[' filename ' [' Name ']; $uploadfile = $dir . $filename; $tp = array ("ImagE/gif "," Image/jpeg "," IMAGE/BMG "," image/jpg "), if (!in_array ($_files[" filename "[" type "], $TP) { echo ' <script>alert ("Allow uploading of picture formats: Jpg/jpeg /gif/bmp ") </script> '; }else{ $r _sc = move_uploaded_file ($_files[' filename '] ["tmp_name"], $uploadfile); echo ' '; }}?>
This article is from the "Shei" blog, make sure to keep this source http://kurol.blog.51cto.com/11433546/1927823
PHP Image upload function implementation