PHP pop-up save dialog box

Source: Internet
Author: User
In the PHP pop-up save dialog box, the problem is as follows:
You need to save the queried table and set it to Excel. the content written to Excel has been completed,
Mainly: 1. when you click Export as Excel, you want to display a selection box for the save path;
2. I hope to control the pop-up in PHP instead of the front-end;
3. is the file path submitted to PHP as a parameter in JavaScript?

Sorry because there are not many scores.


Reply to discussion (solution)

Http://www.cnblogs.com/zcy_soft/archive/2011/06/09/2076728.html

Http://www.cnblogs.com/zcy_soft/archive/2011/06/09/2076728.html



This is totally different from my needs. In addition, my needs are: click export to Excel to bring up the path selection box,
Or you can download it directly, but you need to download it from the browser.

Then you can try a File link directly.

Header ("Content-type: application/vnd. ms-excel "); header (" Content-Disposition: filename=php2excel.xls "); echo iconv (" UTF-8 "," GBK "," name "). "\ t ". iconv ("UTF-8", "GBK", "gender "). "\ n"; foreach ($ get as $ key => $ value) {echo iconv ("UTF-8", "GBK", $ value ["username"]). "\ t ". iconv ("UTF-8", "GBK", $ value ["sex"]). "\ n ";}

Then you can try a File link directly.


Can it be more specific? Because I need to query the database in the background, and then fill the obtained content in EXCEL.

Header ("Content-type: application/vnd. ms-excel "); header (" Content-Disposition: filename=php2excel.xls "); echo iconv (" UTF-8 "," GBK "," name "). "\ t ". iconv ("UTF-8", "GBK", "gender "). "\ n"; foreach ($ get as $ key => $ value) {echo iconv ("UTF-8", "GBK", $ value ["username"]). "\ t ". iconv ("UTF-8", "GBK", $ value ["sex"]). "\ n ";}



Not feasible!

I have carefully inquired about multiple PHPer. At present, the pop-up path selection box should not be available. I can only go back to the next step and show it as a download. the code will be posted later. Thank you!

Suppose that you can define the download and save path as an E disk, but the user only has a D disk. how can this problem be solved? Therefore, you can only select the storage path, but you can define the file name to save, but not the storage path! Personal Understanding

Suppose that you can define the download and save path as an E disk, but the user only has a D disk. how can this problem be solved? Therefore, you can only select the storage path, but you can define the file name to save, but not the storage path! Personal Understanding

If so, you have to consider what if the user is not using windows?

Suppose that you can define the download and save path as an E disk, but the user only has a D disk. how can this problem be solved? Therefore, you can only select the storage path, but you can define the file name to save, but not the storage path! Personal Understanding



So I want to have a path selection process! Instead of customizing the download and save path.


Suppose that you can define the download and save path as an E disk, but the user only has a D disk. how can this problem be solved? Therefore, you can only select the storage path, but you can define the file name to save, but not the storage path! Personal Understanding

If so, you have to consider what if the user is not using windows?



So what I do is download through a browser. no matter what the system [conventional system] is, you can have a browser at least.

$objWriter->save( $fileName );  download( $fileName, true,false ); //exit();function download( $fileName, $delDesFile = false, $isExit = true ) {      if ( file_exists( $fileName ) ) {          header( 'Content-Description: File Transfer' );          header( 'Content-Type: application/octet-stream' );          header( 'Content-Disposition: attachment;filename = ' . basename( $fileName ) );          header( 'Content-Transfer-Encoding: binary' );          header( 'Expires: 0' );          header( 'Cache-Control: must-revalidate, post-check = 0, pre-check = 0' );          header( 'Pragma: public' );          header( 'Content-Length: ' . filesize( $fileName ) );          ob_clean();          flush();          readfile( $fileName );                  if ( $delDesFile ) {              unlink( $fileName );          }          if ( $isExit ) {              exit;          }      }  } 


This is my final solution.

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.