Created
December 1, 2017 22:52
-
-
Save digitalhydra/587a51665ffed0d97c45087b5c2b8b65 to your computer and use it in GitHub Desktop.
download file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if( !empty($_GET['filename']) && !empty($_GET['downloadname']) && file_exists( trailingslashit( wsoe_upload_dir() ).$_GET['filename'].'.csv' ) && wsoe_is_shop_manager() ) { | |
$download_filename = $_GET['downloadname']; | |
$filename = trailingslashit( wsoe_upload_dir() ).$_GET['filename'].'.csv'; | |
$charset = get_option('blog_charset'); | |
$file = fopen( $filename, 'r' ); | |
$contents = fread($file, filesize($filename)); | |
fclose($file); | |
header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); | |
header('Content-Description: File Transfer'); | |
header('Content-Encoding: '. $charset); | |
header('Content-type: text/csv; charset='. $charset); | |
header("Content-Disposition: attachment; filename=$download_filename.csv"); | |
header("Expires: 0"); | |
header("Pragma: public"); | |
$fh = @fopen( 'php://output', 'w' ); | |
fwrite( $fh, $contents ); | |
fclose($fh); | |
exit(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment