PHP + plupload. js implements Multi-graph upload and displays the progress bar plus deleting instance code. plupload. js multi-graph

Source: Internet
Author: User

PHP + plupload. js implements Multi-graph upload and displays the progress bar plus deleting instance code. plupload. js multi-graph

PHP + plupload. js plug-in allows you to upload multiple images and display a progress bar to add and delete instances. If you don't talk much about it, simply upload the code.

HTML code:

<! DOCTYPE html> <? Php $ typeArr = array ("jpg", "png", "gif"); // the file format $ path = "files /"; // upload path if (isset ($ _ POST) {if ($ _ GET ['get'] = "upimg ") {$ name = $ _ FILES ['file'] ['name']; $ size = $ _ FILES ['file'] ['SIZE']; $ name_tmp = $ _ FILES ['file'] ['tmp _ name']; if (empty ($ name )) {echo json_encode (array ("error" => "You have not selected image"); exit;} $ type = strtolower (substr (strrchr ($ name ,'. '), 1); // obtain the object type if (! In_array ($ type, $ typeArr) {echo json_encode (array ("error" => "Clear upload jpg, png, or gif images! "); Exit;} if ($ size> (1024*1024*10) {echo json_encode (array (" error "=>" the image size has exceeded 10 MB! "); Exit;} $ pic_name = time (). rand (10000,999 99 ). ". ". $ type; // image name $ pic_url = $ path. $ pic_name; // path of the uploaded image + name if (move_uploaded_file ($ name_tmp, $ pic_url )) {// transfer the temporary file to the target folder echo json_encode (array ("error" => "0", "pic" => $ pic_url, "name" => $ pic_name);} else {echo json_encode (array ("error" => "Upload error. Check the server configuration! ") ;}} If ($ _ GET ['get'] =" delimg ") {$ imgsrc =$ _ get ['imgurl']; unlink ($ imgsrc); echo 1 ;}}

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.