PHP implementation of Avatar upload preview function _php instance

Source: Internet
Author: User
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.


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.