The problem of passing PHP values in javascript-HTMLJS.

Source: Internet
Author: User
It may be that my idea is not good. what I need to do is select one or more images, click to automatically package the zip file, and then download it. ZIP already exists, PHP does not understand, just make a form on the front end to get multiple image addresses to PHP, and then PHP will traverse and package it into ZIP. PHP {code ...} originally, we wanted to get the specified sr through js... it may be that my idea is not good. what I need to do is select one or more images, click to automatically package the zip file, and then download it.
ZIP already exists, PHP does not understand, just make a form on the front end to get multiple image addresses to PHP, and then PHP will traverse and package it into ZIP.
PHP

$imagee = $_GET['pic'];    foreach ($imagee as $k => $v) {     $image[]= array(            'image_src'  =>$v,            'image_name' => mt_rand(1, 1111) . '.jpg'        );    }

Originally, we wanted to get the specified src through js.
Js

《script》var images = document.getElementsByClassName("1");var imageStr = "";for(var i=0;i
  

The output is a piece of data, and php does not know how to write the loop.
Can you help me?
Obtains the image address of the specified class and sends it to the backend for phpzip packaging.

Reply content:

It may be that my idea is not good. what I need to do is select one or more images, click to automatically package the zip file, and then download it.
ZIP already exists, PHP does not understand, just make a form on the front end to get multiple image addresses to PHP, and then PHP will traverse and package it into ZIP.
PHP

$imagee = $_GET['pic'];    foreach ($imagee as $k => $v) {     $image[]= array(            'image_src'  =>$v,            'image_name' => mt_rand(1, 1111) . '.jpg'        );    }

Originally, we wanted to get the specified src through js.
Js

《script》var images = document.getElementsByClassName("1");var imageStr = "";for(var i=0;i
   

The output is a piece of data, and php does not know how to write the loop.
Can you help me?
Obtains the image address of the specified class and sends it to the backend for phpzip packaging.

$ Imagee = $ _ GET ['Pic ']; foreach ($ imagee as $ k => $ v) {$ image [] = array ('image _ src' => $ v, 'image _ name' => mt_rand (1, 1111 ). '.jpg ');} I think your uploaded variable is a $ _ GET ['Pic'], therefore, you may submit an image at the front end. If you want to submit a group of images, you may refer to the following method: 1.In this way, the $ _ GET ['Pic '] in the background is an array and can be traversed. 2. Use js to json the image address selected at the front end, and assign the valueSubmit the form again, or directly submit the form in js.

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.