PHP Coding
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPHP Coding

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old August 8th, 2002, 07:23 AM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
Force Download with the default filename of the actual file

Hi, currently i have a system set which forces people (on most browsers) to save the pdf document in question to disk. When this document saves the default save name is the name of the script rather then the name of the pdf document. Is there a way for me to make the default save name the actual name of the pdf document? here is my code...

@$fileName = "27xSdox/$filedata.pdf";
@$filesize = filesize($fileName);
if($filesize) {
@Header("Content-Length: ".$filesize);
@Header("Content-Disposition: attachment; filename=".$fileName);
@readfile($fileName);
}

thanks

Reply With Quote
  #2  
Old August 8th, 2002, 08:07 AM
siteworkspro.com siteworkspro.com is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Sydney, Australia
Posts: 92 siteworkspro.com User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via ICQ to siteworkspro.com Send a message via AIM to siteworkspro.com
RE: Force Download with the default filename of the actual file

is there something that you can place in the headers???try
http://www.php.net/header

Reply With Quote
  #3  
Old August 8th, 2002, 08:46 AM
fdqps fdqps is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Malmo, Sweden
Posts: 2 fdqps User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: Force Download with the default filename of the actual file

This works for me:

// $file = only filename.
// $filename = path and name.

header("Content-type: download-application/unknown; name=$filename");

header("Content-Disposition: attachment; filename=$filename");

header("Content-Length: ".filesize($file));

If you are using Mac there is a bug in Microsoft IE which will cause downloads to get the script name. If this is the case please post a new message.

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > Force Download with the default filename of the actual file


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate 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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
Stay green...Green IT