Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jul 2010
    Thanked 0 Times in 0 Posts

    Question 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?

  • #2
    The fat guy next door VIPStephan's Avatar
    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 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).

  • Users who have thanked VIPStephan for this post:

    killjoy (08-06-2010)

  • #3
    Regular Coder
    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.


    Download Link:

    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☠ ☠

  • Users who have thanked Major Payne for this post:

    killjoy (08-06-2010)


    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts