fredted40x Posted September 16, 2010 Share Posted September 16, 2010 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 More sharing options...
micah1701 Posted September 16, 2010 Share Posted September 16, 2010 <a href="/path/to/your/file.doc">Download File</a> Link to comment https://forums.phpfreaks.com/topic/213594-create-a-download-file-link/#findComment-1111757 Share on other sites More sharing options...
fredted40x Posted September 16, 2010 Author Share Posted September 16, 2010 Is it that simple. Thought i tried that a while ago. Do you have to put www.etc in or can it just be /folder1/file.doc. Link to comment https://forums.phpfreaks.com/topic/213594-create-a-download-file-link/#findComment-1111776 Share on other sites More sharing options...
Miss_Rebelx Posted September 16, 2010 Share Posted September 16, 2010 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. Link to comment https://forums.phpfreaks.com/topic/213594-create-a-download-file-link/#findComment-1111801 Share on other sites More sharing options...
chintansshah Posted September 17, 2010 Share Posted September 17, 2010 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');?> Link to comment https://forums.phpfreaks.com/topic/213594-create-a-download-file-link/#findComment-1111985 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.