Javascript file generation to php-php Tutorial

Source: Internet
Author: User
The file generated by javascript is sent to php. This post was last edited by barry963 at 05:06:46, January 14 ,.

Javascript php jquery ajax

Hello everyone, I am working on a website where jquery can automatically generate and download excel files. The function is to use php to send an email as an attachment to the generated excel file. Therefore, the first step is to automatically pass the generated excel file to php. So is there any way for you.

The code for generating an excel file is as follows:

$ (Document ). ready (function () {$ ("# excelExport "). click (function () {var fileexample; // File declaration .... // Generate the file fileexample. click (); // download the file return fileexample ;});});


I have tried some methods and listed them. it may be helpful:
1. the fileexample file in the code, that is, the generated file, is directly sent to php through the POST request of jquery ajax. However, common variables such as strings can be passed.
2. pass the original data of the generated file to php. the file is generated by php, but you do not know how to do it.

Thank you for your help in advance. For the first time I came into contact with such projects, please forgive me for any illustrations.


Reply to discussion (solution)

Pass data to php for php to generate files and send emails

Please refer to PHPExcel class library

Https://github.com/PHPOffice/PHPExcel

The browser's security settings require that the browser Upload files only when the user clicks.
To automatically upload data, you must submit the data directly instead of files.

Thank you, upstairs. let me try it!

We have done this. thank you for choosing to pass the data to PHP and generate a file on the server.

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.