JavaScript-generated files are passed to PHP

Source: Internet
Author: User
This post was last edited by barry963 on 2013-10-14 05:06:46

JavaScript php jquery Ajax

Hello everyone, I am doing a website, the website can be automatically generated by jquery Excel file and download. The function that you want to implement now is to use PHP to send the generated Excel file as an attachment. So, the first step should be to automatically pass the generated Excel file to PHP. So I ask you there is no way.

The code to generate the Excel file is as follows

$ (document). Ready (function () {    $ ("#excelExport"). Click (function () {    var fileexample;//file Declaration ...    .//Generate file                Fileexample.click ();//download file        return fileexample;    });


I have tried some methods, listed, and perhaps helpful:
1. The fileexample file in the code, which is the generated file, is passed directly to PHP via the jquery Ajax POST request and cannot be successful. But ordinary variables, such as strings, can be passed.
2. Pass the raw data of the generated file to PHP, generate the file from PHP, but do not know how to do it.

Thank you in advance for your help. Because of the first contact with such items, what is the pattern of Tucson broken place please forgive us.


Reply to discussion (solution)

Pass data to PHP to have PHP generate files and send messages

Please consult the Phpexcel class library

Https://github.com/PHPOffice/PHPExcel

The browser's security settings require the browser to upload files only if the user clicks on it.
If you want to upload automatically, you should submit the data directly instead of the file.

Thank you upstairs two, I try!

It's done, thank you. Finally, the data is passed to PHP, and the file is generated on the server side.

  • 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.