/    Sign up×
Community /Pin to ProfileBookmark

Download Manager / Save As Dialog Box

Hi,

I would like to know how I can force to browser to start a download of a file from my site with the save-as dialog box. This is to ensure PDF, DOC, and music files are not loaded automatically.

Thanks!

Daniel Loh

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@darkestnightOct 07.2004 — If you set the MIME type to something else, then the browser plugins will not try to load them when you click them.
Copy linkTweet thisAlerts:
@JavaHead_JonnieOct 07.2004 — [code=php]<?php
$file = '/var/www/html/file-to-download.xyz';
header('Content-Description: File Transfer');
header('Content-Type: application/force-download');
header('Content-Length: ' . filesize($filename));
header('Content-Disposition: attachment; filename=' . basename($file));
readfile($file);
?>[/code]
×

Success!

Help @danlohye spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.6,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...