Is there a plugin for uploading multiple images at a time? As with discuz posting, multiple images are uploaded at a time, and all uploaded image paths are inserted into the editor.
?
Reply to discussion (solution)
Find a JS batch upload plug-in, which is mainly beautiful and technically a form.
From the http protocol implementation perspective, the following php code is a living protocol details:
$val) { $data .= "--$boundary\n"; $data .= "Content-Disposition: form-data; name=\"".$key."\"\n\n".$val."\n"; } $data .= "--$boundary\n"; //Collect Filedata foreach($files as $key => $file) { $fileContents = file_get_contents($file['tmp_name']); $data .= "Content-Disposition: form-data; name=\"{$key}\"; filename=\"{$file['name']}\"\n"; $data .= "Content-Type: image/jpeg\n"; $data .= "Content-Transfer-Encoding: binary\n\n"; $data .= $fileContents."\n"; $data .= "--$boundary--\n"; } $params = array('http' => array( 'method' => 'POST', 'header' => 'Content-Type: multipart/form-data; boundary='.$boundary, 'content' => $data )); $ctx = stream_context_create($params); $fp = fopen($url, 'rb', false, $ctx); if (!$fp) { throw new Exception("Problem with $url, $php_errormsg"); } $response = @stream_get_contents($fp); if ($response === false) { throw new Exception("Problem reading data from $url, $php_errormsg"); } return $response; } //set data (in this example from post) //sample data $postdata = array( 'name' => $_POST['name'], 'age' => $_POST['age'], 'sex' => $_POST['sex'] ); //sample image $files['image'] = $_FILES['image']; do_post_request("http://example.com", $postdata, $files); ?>
Swfopload
This post was last edited by PhpNewnew at 10:56:05
When learning PHP, you may encounter the problem of uploading multiple images in PHP. to upload images, you must verify the image format to ensure that images are uploaded and other files are not uploaded to the server. The basic implementation method of multi-image upload is to use arrays to submit all images to an array and process the elements of the array cyclically. The following is an example of PHP multi-image upload code:
1. 2. // image directory
3. $ img_dir = "../upload /";
4 .//...... Html display Upload interface
5./* image Upload processing */
6. // upload the image to the server
7. // initialize the variable
8. $ uploaded = 0;
9. $ unuploaded = 0;
10. // only five images can be uploaded
11. for ($ I = 0; $ I <= 5; $ I ++)
12 .{
13. // obtain the information of the current image
14. $ is_file = $ _ FILES ['imgfile'] ['name'] [$ I];
15. // if the current image is not empty
16. if (! Empty ($ is_file ))
17 .{
18. // store the information of the current image to the variable
19. $ result [$ I] ="
20.
21.". $ _ FILES ['imgfile'] ['name'] [$ I]."
22.". Round ($ _ FILES ['imgfile'] ['size'] [$ I]/1024,2)." K
23.". $ _ FILES ['imgfile'] ['type'] [$ I]."
24.";
25. // Determine whether the type of the uploaded image is jpg, gif, png, or bmp, and whether the upload is successful.
26. if (
27. $ _ FILES ['imgfile'] ['type'] [$ I] = "image/pjpeg" |
28. $ _ FILES ['imgfile'] ['type'] [$ I] = "image/gif" |
29. $ _ FILES ['imgfile'] ['type'] [$ I] = "image/x-png" |
30. $ _ FILES ['imgfile'] ['type'] [$ I] = "image/bmp"
31 .)
32 .{
33. // if the uploaded file does not exist on the server
34. if (! File_exists ($ img_dir. $ _ FILES ['imgfile'] ['name'] [$ I])
35 .{
36. // transfer the image file from the temporary folder to the directory we specified to Upload
37. move_uploaded_file ($ _ FILES ['imgfile'] ['tmp _ name'] [$ I],
38. $ img_dir. $ _ FILES ['imgfile'] ['name'] [$ I]);
39. $ result [$ I]. = "successful ";
40. $ uploaded ++;
41 .}
42. else // if the file already exists on the server
43 .{
44. $ result [$ I]. = "the file already exists ";
45. $ unuploaded ++;
46. continue;
47 .}
48 .}
49. else
50 .{
51. $ result [$ I]. = "failed ";
52. $ unuploaded ++;
53 .}
54. $ result [$ I]. ="";
55.} // endif
56.} // endfor
57. // if no image is selected
58. if (empty ($ result ))
59 .{
60. prompt_msg ("error message", "No image is selected. "," Back to the previous step "," uploadimg. php? Action = upload ");
61. exit ();
62 .}
63. // display all uploaded results
Reply by referencing the author:
As with discuz posting, multiple images are uploaded at a time, and all uploaded image paths are inserted into the editor.
?
There is a program on the Internet that imitates the QQ album Upload plug-in.
Xproer. ImageUploader: http://www.cnblogs.com/xproer/archive/2010/08/09/1796077.html
Main interface
Image list
Add image
Edit image:
Prompt message:
This is a strong WEB image upload control that our company used to upload a website last time to customers.
Reply by referencing the author:
As with discuz posting, multiple images are uploaded at a time, and all uploaded image paths are inserted into the editor.
?
There is a program on the Internet that imitates the QQ album Upload plug-in.
Xproer. ImageUploader: http://www.cnblogs.com/xproer/archive/2010/08/09/1796077.html
Main interface
Image list
Add image
Edit image:
Prompt message:
This user experience is good. Now internet products are getting better and better, and users are getting more and more convenient to use.
Reply by referencing the author:
As with discuz posting, multiple images are uploaded at a time, and all uploaded image paths are inserted into the editor.
?
There is a program on the Internet that imitates the QQ album Upload plug-in.
Web image bulk upload control (Xproer. ImageUploader): http://www.cnblogs.com/xproer/archive/2010/08/09/1796077.html
Main interface
Image list
Add image
Edit image:
Prompt message:
Integrated code
Web image batch upload control demo page