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.