Php implements the Avatar upload preview function, and php Avatar upload Preview
The example in this article shares with you the specific code for php to implement the Avatar upload preview function for your reference. The specific content is as follows:
Home Page 1.php
<Html>
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"]; // path of the Avatar storage $ filename = iconv ("UTF-8", "gb2312", $ fname ); if (file_exists ($ filename) {echo "<script> alert ('the file is saved In! '); </Script> ";}else {move_uploaded_file ($ _ FILES [" file "] [" tmp_name "], $ filename ); unlink ($ _ POST ["tp"]); echo "<script> parent. showimg ('{$ fname}'); </script> ";}}}
Show:
Click the image position to display the selection box:
After the image is selected:
The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.