westman Posted August 5, 2012 Share Posted August 5, 2012 hi all,am looking for a way users can download a file from my site if my file is...www.mysite.com/files/15.png how do i right the script to download it? Link to comment Share on other sites More sharing options...
birbal Posted August 5, 2012 Share Posted August 5, 2012 when you request a file, the browser downloads it everytime. it will usually prompt to download unless the specifed file has any plugin installed to show the file in browser (eg like pdf file, or realone player uses a plugin to show videos) You can use header("content-disposition:attachment"); to force download rather than showing it in the browser. Link to comment Share on other sites More sharing options...
birbal Posted August 5, 2012 Share Posted August 5, 2012 http://in3.php.net/manual/en/function.header.php there is some example Link to comment Share on other sites More sharing options...
westman Posted August 5, 2012 Author Share Posted August 5, 2012 so using... $down_file = "www.mysite.com/files/15.png"; header('Content-Disposition: attachment; filename="pic.png"'); where do i put $down_file? Link to comment Share on other sites More sharing options...
birbal Posted August 6, 2012 Share Posted August 6, 2012 (edited) $down_file = "www.mysite.com/files/15.png"; header("Content-Disposition: attachment; filename=pic.png"); readfile($down_file); Edited August 6, 2012 by birbal Link to comment Share on other sites More sharing options...
westman Posted August 6, 2012 Author Share Posted August 6, 2012 thank you Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now