Hee hee hee, since Christmas, I have been lazy. Because of being too busy these days, I feel that I haven’t come out for a long time, eh ...
I have been struggling for life. As a front-end development engineer, I am becoming more and more confused. I don’t know who I am now. Will html5 and css3 be the front end? Do you know PHP as a front-end? Will smarty be the front end? Do you know JavaScript as a front-end? Do you know jQuery is the front-end? Does Ajax work as a front-end?是 Will various frameworks are the front end?
are now increasingly felt that I am not a front-end person anymore. I have learned a lot and used it in various ways. Is this the fate of the front-end?
Website front-end:
For a website, the front-end usually refers to the front-end part of the website including the presentation layer and structural layer of the website. Therefore, front-end technology is generally divided into front-end design and front-end development. Front-end design can generally be understood as the visual design of the website, and front-end development is the front-end code implementation of the website, including basic HTML, CSS and JavaScript/ajax. Now the latest advanced version is HTML5, CSS3, and SVG, etc.
I recently came into contact with some PHP stuff and it feels pretty good, so I’d better share it with you!
php avatar upload:
1, html
<html> <head> <title>图片上传title> <style type="text/css"> body {font-size: 14px;} style> head> <body> <form enctype="multipart/form-data" method="post" name="upform"> 上传文件: <input name="upfile" type="file"> <input type="submit" value="上传"><br> form>
php //上传文件类型列表 $uptypes=array( 'image/jpg', 'image/jpeg', 'image/png', 'image/pjpeg', 'image/gif', 'image/bmp', 'image/x-png' ); $max_file_size=2000000; //上传文件大小限制, 单位BYTE $destination_folder="uploadimg/"; //上传文件路径 $cun="../../images/uploadimg/"; $imgpreview=1; //是否生成预览图(1为生成,其他为不生成); $imgpreviewsize=1/2; //缩略图比例 ?>
Simply define the format and other parameters for image upload,
3. Specific judgment method
php if ($_SERVER['REQUEST_METHOD'] == 'POST') { if (!is_uploaded_file($_FILES["upfile"][tmp_name])) //是否存在文件 { echo "图片不存在!"; exit; } $file = $_FILES["upfile"]; if($max_file_size < $file["size"]) //检查文件大小 { echo "文件太大!"; exit; } if(!in_array($file["type"], $uptypes)) //检查文件类型 { echo "文件类型不符!".$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 "同名文件已经存在了"; exit; } if(!move_uploaded_file ($filename, $destination)) { echo "移动文件出错"; exit; } if($imgpreview==1) { echo "
图片预览:
"; echo "$destination."\" width=".($image_size[0]*$imgpreviewsize)." height=".($image_size[1]*$imgpreviewsize); echo " alt=\"图片预览:\r文件名:".$destination."\r上传时间:\">"; } } ?>
Anyway, it’s just a blind cat encountering a dead mouse, and the result is such a willful effect, hehe, the storage path of the generated image is a key, just pay attention to it!
The above introduces PHP avatar uploading, including aspects of content. I hope it will be helpful to friends who are interested in PHP tutorials.