user1630769
user1630769

Reputation: 43

file download through php code

i've created a php file which shows data from database:

http://www.eedmoe.gov.bd/report/app/webroot/files/uploaded/tenders/tender.php

But I want to download files. Report.doc, contact.txt, etc files are saving this folder:

http://www.eedmoe.gov.bd/report/app/webroot/files/uploaded/tenders/

I want that any visitor or user can download those files by clicking or save as. What should be the php function or code am I going to use?

Upvotes: 0

Views: 1005

Answers (2)

Art Planteur
Art Planteur

Reputation: 533

You can also make a specific page to force download if you don't want it to be opened by the browser :

<?php header("Content-Type: application/force-download"); ?>

See Doc here

Upvotes: 1

hek2mgl
hek2mgl

Reputation: 157947

Change the href attribute of the links to the filenames. To download 'contact.txt' for example use this link in your html:

<a href="contact.txt">contact.txt</a>

You'll need no php for this.

Upvotes: 1

Related Questions