Results 1 to 5 of 5

Thread: Download File from WEB Site

  1. #1
    Join Date
    Jun 2006
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Download File from WEB Site

    Could someone give me the code for downloading a file from my web site without using Active X Code. Thanks

  2. #2
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    Depends on the file type. For example, if you make a .zip file it will prompt the visitor to download once they browse to the file name...

    or you can try something like this (untested):

    Code:
    <? php
    function force_download($file) 
    { 
        $dir      = "../log/exports/"; 
        if ((isset($file))&&(file_exists($dir.$file))) { 
           header("Content-type: application/force-download"); 
           header('Content-Disposition: inline; filename="' . $dir.$file . '"'); 
           header("Content-Transfer-Encoding: Binary"); 
           header("Content-length: ".filesize($dir.$file)); 
           header('Content-Type: application/octet-stream'); 
           header('Content-Disposition: attachment; filename="' . $file . '"'); 
           readfile("$dir$file"); 
        } else { 
           echo "No file selected"; 
        } //end if 
    
    }//end function 
    ?>
    orrrrr... take a look here: http://elouai.com/force-download.php

    However, I don't think any of these methods are completely cross browser compatable.
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  3. #3
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Code:
        } //end if 
    
    }//end function
    And that, folks, is how not to comment code.

    The idea is to explain bits that might not make sense, not to point out the blatantly obvious and leave the rest undocumented.

    roger38: How files are handled is entirely up to the user. The best you can do is stick it in a ZIP archive, but even that won't necessarily cause the effect you want, if the user has their browser set up otherwise.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  4. #4
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    Quote Originally Posted by Twey
    And that, folks, is how not to comment code.

    The idea is to explain bits that might not make sense, not to point out the blatantly obvious and leave the rest undocumented.

    LOL I said untested, I didn't say I wrote it... You know I couldn't do that... yet... I am still on page 3 of the W3 school, LMAO!
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  5. #5
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    I said untested, I didn't say I wrote it
    Hahaha, fair enough
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

Bookmarks

Posting Permissions

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