force-download

PHP create file for download without saving on server

六眼飞鱼酱① 提交于 2019-11-27 00:35:51
问题 Ultimate goal: I want to create a webpage where a user can enter information in forms. With that information I want to create a html file (below called test-download.html) by inserting the information given into a template and then force a download. Since I want to demonstrate this at an upcoming workshop where people will be using this at the "same time" I would like to not save the file on the server and just force the download. So far: I have this in my html file (test.html): <form action=

send zip file to browser / force direct download

随声附和 提交于 2019-11-26 20:56:33
问题 i created with php zip ( http://php.net/manual/de/book.zip.php ) a zip file now i have to send it to the browser / force a download for it. 回答1: <?php // or however you get the path $yourfile = "/path/to/some_file.zip"; $file_name = basename($yourfile); header("Content-Type: application/zip"); header("Content-Disposition: attachment; filename=$file_name"); header("Content-Length: " . filesize($yourfile)); readfile($yourfile); exit; ?> 回答2: Set the content-type, content-length and content

Force Download an Image Using Javascript

回眸只為那壹抹淺笑 提交于 2019-11-26 08:10:05
I want to know if there is any way to make a script using Javascript/jQuery to download (open a download dialog) a image so the browser won't just show it. Salman A You need to use server-side scripting for this. Search on stackoverflow . Alternately, your server might allow you to alter headers dynamically via configuration. Apache solution with mod_headers Place your downloadable images in a directory. Inside this directory, create a .htaccess file with the following contents: SetEnvIf Request_URI "([^/]+\.jpg)$" REQUESTED_IMAGE_BASENAME=$1 SetEnvIf Request_URI "([^/]+\.png)$" REQUESTED

Force Download an Image Using Javascript

送分小仙女□ 提交于 2019-11-26 01:59:20
问题 I want to know if there is any way to make a script using Javascript/jQuery to download (open a download dialog) a image so the browser won\'t just show it. 回答1: You need to use server-side scripting for this. Search on stackoverflow. Alternately, your server might allow you to alter headers dynamically via configuration. Apache solution with mod_headers Place your downloadable images in a directory. Inside this directory, create a .htaccess file with the following contents: SetEnvIf Request