PHP Avatar Upload

Source: Internet
Author: User
Hehe, since after Christmas, has been lazy, these days also because is too busy reason, feel for a long time have not come out to take bubble, eh ...

In order to live has been struggling, as a front-end development engineer, I am now more and more confused, do not know what the hell I am now?

Would HTML5 and from CSS3 be the front?

Will PHP be the front end?

Will smarty be the front end?

Will JavaScript be the front end?

Would jquery be the front end?

Will Ajax be the front end?

Will the various frameworks be front-end?

In short now more and more feel that they are not a front-end personnel, learning more, with the miscellaneous, this is the fate of the front end?

Website Front End:

Front-end for a website, usually refers to the site's foreground part includes the site's performance layer and structure layer. So the front-end technology is generally divided into front-end design and front-end development, the front-end design can generally be understood as the visual design of the site, front-end development is the site's foreground code implementation, including basic HTML and CSS and Javascript/ajax, now the latest advanced version is HTML5, CSS3, , as well as SVG.

Recently touched some php things, feel good, so still share with you!

PHP Avatar Upload:

1. html

<HTML>  <Head>  <title>Image upload
  title>  <styletype= "Text/css">Body{font-size:14px;}   
     style> 
      head><body>  <form  enctype= "Multipart/form-data"  method= "POST"  name= "Upform">  upload file:  <input  C23>name= "Upfile"  type= "file"><input  type= "Submit"  value= "Upload"><br  > 
       form> 
    
                  
   


2, PHP upload avatar

 
  // upload file type list   $uptypes=array(      ' image/jpg ',      ' image/jpeg ',      ' image/png ',      ' image/ Pjpeg ',      ' image/gif ',      ' image/bmp ',      ' image/x-png '  ); $max _file_size=2000000;     // upload file size limit, unit byte   $destination _folder // upload file path   $cun= ". /.. /images/uploadimg/"; $imgpreview=1;      // whether to generate a preview map (1 is generated, others are not generated  ); $imgpreviewsize=1/2;    // thumbnail scale   ? >

A simple definition of the image Upload format and some other parameters,

3, the specific method of judgment

 Phpif($_server[' request_method '] = = ' POST ')   {       if(!Is_uploaded_file($_files["Upfile"][tmp_name]))//whether the file exists     {           Echo"The picture doesn't exist!"; Exit; }        $file=$_files["Upfile"]; if($max _file_size<$file["Size"])      //Check File size    {          Echo"The file is too big!"; Exit; }        if(!In_array($file["Type"],$uptypes))      //Check file Types    {          Echo"File type does not match!".$file["Type"]; Exit; }        if(!file_exists($destination _folder))      {          mkdir($destination _folder); }        $filename=$file["Tmp_name"]; $image _size=getimagesize($filename); $pinfo=PathInfo($file["Name"]); $ftype=$pinfo[' extension ']; $destination=$destination _folder. Time().".".$ftype; if(file_exists($destination) &&$overwrite!=true)      {          Echo"File with the same name already exists"; Exit; }        if(!Move_uploaded_file($filename,$destination))      {          Echo"Move File Error"; Exit; }        if($imgpreview==1)      {      Echo"
Picture preview:
"; Echo"$destination." \ "Width=". ($image _size[0]*$imgpreviewsize). "Height=". ($image _size[1]*$imgpreviewsize); Echo"Alt=\" Picture preview: \ r file name: ".$destination." \ r upload time: \ ">"; } }?>

Anyway, the blind cat ran into a dead mouse, but also so willful effect on out, hehe, where the picture generated by the storage path is a key, pay attention to the good!

The above describes the PHP avatar upload, including aspects of the content, I hope the PHP tutorial interested in a friend helpful.

  • Related Article

    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.