Php Upload image-PHP source code

Source: Internet
Author: User
Upload image code

Function Upload ($ file_name, $ path, $ pub, $ size = 204800) {// function Upload ($ file_name, $ path, $ pub) {$ type = implode (", ", $ pub); $ root = $ _ SERVER ['document _ root']; // find the site ROOT path $ image = $ _ FILES [$ file_name]; // the value of the received file field (an array) if ($ image ['name'] = "") {return "" ;}$ upload_path = $ root. $ path; // set the location of the uploaded file $ leixing = strtolower (strrchr ($ image ['name'], ". "); // put the uploaded file name". "All subsequent lowercase letters (get the file extension) $ suijishu = rand (100,999); // Obtain a random number of 100--999; $ server_file = time (). $ suijishu. $ leixing; // Get the Upload file name (timestamp plus random number plus extension) if (in_array ($ leixing, $ pub) {// Determine the extension (set the upload type) /* if ($ image ['size']> $ size) {// compare the size and even size of the uploaded file echo"

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.