Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
08-03-2010, 12:41 AM #1
- Join Date
- Jul 2010
- Thanked 0 Times in 0 Posts
Need code for download of wordpad doc.
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 #2
- Join Date
- Jan 2006
- Halle (Saale), Germany
- Thanked 1,040 Times in 1,013 Posts
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 link with preview image would be:Code:<a href="path/to/document.rtf">document.rtf (32 KB)</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).Code:<a href="path/to/document.rtf"><img src="path/to/preview_image.jpg" alt="document.rtf" /></a>
Users who have thanked VIPStephan for this post:
08-03-2010, 08:38 PM #3
- Join Date
- Aug 2005
- Thanked 79 Times in 77 Posts
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-h...force-download
☠ ☠RON☠ ☠