Jump to content

Create a download file link


fredted40x

Recommended Posts

Hi,

 

Just looking how to create a link to download a file located on the server, it will be files like .doc etc.

 

Cant seem to find anything on the net so i think i need php but may be html.

 

Can anyone point me in the right direction?

 

Thanks

 

p.s. it will be used for more than one file so im looking for a small ish amount of code.

Link to comment
https://forums.phpfreaks.com/topic/213594-create-a-download-file-link/
Share on other sites

It all depends... is it a local file? If you can reach it within your domain, you can use a relative path (/folder/file.ext). Otherwise, if it's somewhere else for example on a different server, then use an absolute path (http://www....). More info can be found via google.

you can use <a > tag but if you are trying to do with .txt file then it's open in browser only not give a popup to download. Please visit below link and code to implement download file.

 

http://php.net/manual/en/function.header.php

 

 

<?php// We'll be outputting a PDFheader('Content-type: application/pdf');// It will be called downloaded.pdfheader('Content-Disposition: attachment; filename="downloaded.pdf"');// The PDF source is in original.pdfreadfile('original.pdf');?>

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.