Reply
file download problem
Old 11-19-2007, 11:13 PM file download problem
Novice Talker

Posts: 5
Name: Leo
Basically my only problem is I have a set of individual vcard that I have separate links going to each one. The only problem is when the user clicks on the link it opens the file and does not save. What I need is to know exactly how to have the link when clicked upon, open up a open save cancel dialogue box. I currently do not have any code, but if i use code php is the language I would rather use.Thanks for the help
bigleo23 is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 11-20-2007, 05:29 AM Re: file download problem
maxxximus's Avatar
Extreme Talker

Posts: 190
Name: Rob
Location: UK
Best solution is to offer 'right click save as' instead of forcing download.

You could use .htaccess in your download directory written

Code:
 <Files *.vcf >
  ForceType application/octet-stream
  Header set Content-Disposition attachment
</Files>
This may work for Mozilla clients but IE may cause problems.

Could you not zip the .vcf files as zips always force a download.

Also theres a scripting solution by linking your vcf file to 'download.php' script. This is a possible solution for a single file only which is hard coded into the script. There are security issues if done dynamically although sure theres a solution if you Google it. This script hasn't been tested - but something along these lines.

Code:
// download.php

$path = "foo.vcf"; // hard coded vcf file here
try {
if (is_file ($path)){
if ($file = fopen($path, 'rb')) {
while(!feof($file) and (connection_status()==0)) {
$f .= fread($file, 1024*8);
}
fclose($file);
}
//Use the header function 
$outputname = "anyName";
header ("Content-type: text/x-vcard ");
//This will force a download.
header("Content-disposition: attachment; filename=".$outputname.".vcf");
print $f;
} else {
throw new exception ("Sorry, file path is not valid.");
}
} catch (exception $e){
echo $e->getmessage();
}

Last edited by maxxximus : 11-20-2007 at 05:32 AM.
maxxximus is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to file download problem
 

Thread Tools

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.12132 seconds with 12 queries