Allow users to download files outside webroot

Use a symlink pointing to /var/uploads (tutorial here) a Apache Alias directive Alias /uploads /var/uploads (must be in httpd.conf) or a proxy PHP script that accepts a GET variable filename=upload.jpg and fetches the file e.g. using fpassthru() the latter is the least preferable option because it is resource intensive, but sometimes it’s the only alternative. … Read more

Response.AddHeader(“Content-Disposition”) not opening file in IE6

i have found the problem in IE 6 we have to read the content and use buffers and binary write to open file in IE 6,, the code below works fine for me in IE6 FileStream sourceFile = new FileStream(Server.MapPath(@”FileName”), FileMode.Open); float FileSize; FileSize = sourceFile.Length; byte[] getContent = new byte[(int)FileSize]; sourceFile.Read(getContent, 0, (int)sourceFile.Length); sourceFile.Close(); … Read more

Conditionally provide either file download or show export validation error message

Is there any generally acceptable way of solving issues like this one? You basically want to fire an ajax request first and in its oncomplete check if it’s successful, and then trigger a synchronous request to download the file (note that you can’t download files with ajax). You could make use of FacesContext#validationFailed() (or OmniFaces … Read more

Open Download Dialog with PHP

Content-Disposition header.. // We’ll be outputting a PDF header(‘Content-type: application/pdf’); // It will be called downloaded.pdf header(‘Content-Disposition: attachment; filename=”downloaded.pdf”‘); // The PDF source is in original.pdf readfile(‘original.pdf’); http://au2.php.net/manual/en/function.header.php

Download a file through the WebBrowser control

Add a SaveFileDialog control to your form, then add the following code on your WebBrowser’s Navigating event: private void webBrowser1_Navigating(object sender, WebBrowserNavigatingEventArgs e) { if (e.Url.Segments[e.Url.Segments.Length – 1].EndsWith(“.pdf”)) { e.Cancel = true; string filepath = null; saveFileDialog1.FileName = e.Url.Segments[e.Url.Segments.Length – 1]; if (saveFileDialog1.ShowDialog() == DialogResult.OK) { filepath = saveFileDialog1.FileName; WebClient client = new WebClient(); client.DownloadFileCompleted … Read more

Supporting resumable HTTP-downloads through an ASHX handler?

Thanks icktoofay for getting me started, here’s a complete example to save other developers some time: Disk Example /// <summary> /// Writes the file stored in the filesystem to the response stream without buffering in memory, ideal for large files. Supports resumable downloads. /// </summary> /// <param name=”filename”>The name of the file to write to … Read more