Php implements the Avatar upload preview function, and php Avatar upload Preview

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.