Topic awaiting preservation: Presenting a file for download without creating the file? (Page 1 of 1) |
|
---|---|
Bipolar (III) Inmate From: Australia |
posted 08-02-2005 02:20
Anyone know if its possble to I guess have a chunk of text, and present this as a file to download - without actually creating the file on the server. |
Maniac (V) Mad Librarian From: Seoul, Korea |
posted 08-02-2005 11:44
Ya got me there. If I understand what you're saying, I imagine that it might not be possible. What you're basically trying to do is download a dynamically created file directly to the user's system, right? Even if it is possible, sounds like a very abusable thing to do. How does the user know you're not going to dynamically create a self-executing virus? It's hard enough to trust downloads as it is. |
Bipolar (III) Inmate From: Australia |
posted 08-02-2005 12:29
Ah ok, all it is is for my website statistics. I show the graphs and all that and want to offer them the ability to download the csv file. |
Maniac (V) Mad Librarian From: Seoul, Korea |
posted 08-02-2005 15:01
Hmmm... OK, I've never tried anything like this, but I'm wondering if the answer isn't something simple. For example, could you create a link to the csv file and then just have people save that using the context menu (i.e., right-click for PC users)? I don't see why that wouldn't work, as you long as you can provide a link to the dynamic content. |
Maniac (V) Inmate From: under the bed |
posted 08-02-2005 16:29
He's looking to offer the csv file without actually having the csv file on the server - grab the data, create the file, but save it only on the client machine and not on the server. |
Bipolar (III) Inmate From: Australia |
posted 08-02-2005 17:10
No worries, thanks all - its easy enough to do it the other, just makes more interesting to look at doing something special! :P |
Paranoid (IV) Inmate From: Madison, Indiana, USA |
posted 08-02-2005 17:57
Yes it is definitely possible to send text to the client without first creating it as a file on the server. I assume you are creating the data using a server side program in Perl or PHP. |
Paranoid (IV) Mad Scientist with Finglongers From: Germany |
posted 08-02-2005 22:57
Here's the skinny: code: <?php // We'll be outputting a PDF header('Content-type: application/pdf'); //application/octet-stream would be good if you have more or less unspecified data, and don't want the browser to handle it // It will be called downloaded.pdf header('Content-Disposition: attachment; filename="downloaded.pdf"'); // The PDF source is in original.pdf - or print whatever you want. readfile('original.pdf'); ?> |
Bipolar (III) Inmate From: Australia |
posted 08-03-2005 02:03
Ah thanks for that, im pretty silly i should have looked at the code i did recently for a normal file download module which does a simliar thing, perhaps instead of reading the file I can just use my text!! Will give it a go and let you know how it turns out. |
Maniac (V) Mad Librarian From: Seoul, Korea |
posted 08-03-2005 03:37
Ah... I get it now. Hope everything works out. |
Paranoid (IV) Mad Scientist with Finglongers From: Germany |
posted 08-03-2005 09:12
uh... I have no idea. Think the Doc taught me that particular colloquial phrase. |
Bipolar (III) Inmate From: Australia |
posted 08-03-2005 09:41
Heh i didn't really notice till it was pointed out - to be honest i dont think i've seen it used anywhere before :P |