This article mainly for you in detail the implementation of the PHP Avatar upload preview function of the relevant information, with a certain reference value, interested in small partners can refer to
Main Page 1.php
Processing page 2.php
<?phpsession_start (); $uid = $_session["UID"];if ($_files["File" ["Error"]) { echo $_files["file"] ["Error"];} else{ if (($_files["file"] ["type"]== "Image/jpeg" | | $_files["FILE" ["Type"]== "Image/png") && $_files[" File "[" Size "]<1024000) { $fname ="./a/image/". Date (" Ymdhis "). $_files[" File "[" name "]; The path of the Avatar store $filename = Iconv ("UTF-8", "gb2312", $fname); if (file_exists ($filename)) { echo "<script>alert (' the file already exists! ');</script> "; } else { move_uploaded_file ($_files["file"] ["Tmp_name"], $filename) ; Unlink ($_post["TP"]); echo "<script>parent.showimg (' {$fname} ');</script>";}} }
Open the display:
Click the picture location pop-up selection box:
After you select the picture is complete:
The above is the whole content of this article, I hope that everyone's study has helped.