View Full Version : Need code for download of wordpad doc.
08-03-2010, 12:41 AM
I'm a beginner. Is it possible to place a code on a webpage for people to see a simple wordpad document (that you've uploaded to your site) so that when they click on it, they can either open the document or save it?
08-03-2010, 01:05 AM
You would just put a simple anchor (=link) that points to the file (which should be stored on the server somewhere). If you want a preview of the document you should make a screenshot of it, modify it accordingly in some graphics program (i. e. edit image dimensions and file size etc.), and put it in that anchor.
A text link would look like this:
<a href="path/to/document.rtf">document.rtf (32 KB)</a>
A link with preview image would be:
<a href="path/to/document.rtf"><img src="path/to/preview_image.jpg" alt="document.rtf" /></a>
Both, the image and the document must be uploaded to the server, too. Then, if somebody clicks the link they are prompted to download the file (or downloading automatically, depending on their browser settings).
08-03-2010, 08:38 PM
If the browser has a program associated with the file extension, it will use that program to open the file. That's why you need Adobe's Reader plug-in to view PDFs in your browser. There is an option to save from any browser File menu once the file has been open for viewing. If Word is called instead to open the file, then they can save the file from Word itself. If you want a download option, zip the file and provide that as the link with appropriate text description.
You have to zip the file to trigger the browser's response to Save File. Otherwise, it will call a program to play the media file.
How to Zip or Unzip a file:
Making an image a link:
<p><a href="URL path to zipped file" title="Mouseover Description"><img style="width: XXpx; height: YYpx; border: 0;" src="Path to image" alt="Text Description"></a></p>
Text Link only:
<p><a href="URL path to zipped file" title="Mouseover Description">Link Text Description</a></p>
You can change the "p" tags to div tags and style as needed.
Forcing File Downloads in PHP: http://elouai.com/force-download.php
Using PHP Headers to Force Download: http://www.ryboe.com/tutorials/php-headers-force-download
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.