Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
05-25-2006, 03:32 PM
|
#1
|
|
Senior Member
Registered: Apr 2003
Location: Colombia
Distribution: Kubuntu, Debian, Knoppix
Posts: 1,905
Rep:
|
php: is it possible to change the name of a download?
I'm working on downloading the attachments of mails (working with IMAP).
I want to know if it's possible to set the name of the file the person will download? I know the Content-type can be set with a header so the web agent knows what type of file is being downloaded... however, is there a way I can tell the agent the file name? I didn't find an http header to do it on rfc2616.
|
|
|
|
05-26-2006, 08:27 AM
|
#2
|
|
Member
Registered: Mar 2003
Location: Berkshire, England.
Distribution: SuSE 10.0
Posts: 299
Rep:
|
You're right, I'm not sure it can be done in the http headers. I'd typically use mod-rewrite to achieve that sort of thing.
|
|
|
|
05-26-2006, 08:28 AM
|
#3
|
|
Moderator
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 42,816
|
i have an asp script which includes
Code:
Response.AddHeader "Content-Disposition","attachment; filename=Blah blah blah.csv"
so i'd assume the Content-Disposition header would work jstu as well when php generated.
|
|
|
|
05-26-2006, 08:34 AM
|
#4
|
|
Member
Registered: Aug 2003
Location: Montpellier, France, Europe, World, Solar System
Distribution: Debian Sarge, Fedora core 5 (i386 and x86_64)
Posts: 262
Rep:
|
The good source is always the documentation.... Extracted from http://php.net/manual/en/function.header.php
Quote:
|
Originally Posted by php documentation
If you want the user to be prompted to save the data you are sending, such as a generated PDF file, you can use the Content-Disposition header to supply a recommended filename and force the browser to display the save dialog.
Code:
<?php
// 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');
?>
|
For the exact rfc, chapter 15.5 of rfc2616 ("Content-Disposition Issues") refers to rfc2183
Last edited by zeitounator; 05-26-2006 at 09:17 AM.
|
|
|
|
05-26-2006, 02:30 PM
|
#5
|
|
Senior Member
Registered: Apr 2003
Location: Colombia
Distribution: Kubuntu, Debian, Knoppix
Posts: 1,905
Original Poster
Rep:
|
Thanks, guys! :-)
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 01:07 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|