Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 11 of 11
  1. #1
    Banned
    Join Date
    Oct 2007
    Posts
    52
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Download on Access

    Using PHP, how do I display the download dialog, in order to download a file, upon a page being accessed?

  • #2
    Senior Coder
    Join Date
    Jan 2007
    Posts
    1,648
    Thanks
    1
    Thanked 58 Times in 54 Posts

  • #3
    Banned
    Join Date
    Oct 2007
    Posts
    52
    Thanks
    0
    Thanked 0 Times in 0 Posts
    So I need to use?:

    Code:
    header('Content-Disposition: attachment; filename="downloaded.pdf"');
    How do I use a path from a database, as the filename?

  • #4
    Senior Coder
    Join Date
    Jan 2007
    Posts
    1,648
    Thanks
    1
    Thanked 58 Times in 54 Posts
    Just concatenate the variable into the string.

  • #5
    Banned
    Join Date
    Oct 2007
    Posts
    52
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Like What?

  • #6
    Banned
    Join Date
    Oct 2007
    Posts
    52
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Why doesn't the following code work?
    I get the following error message:

    Parse error: syntax error, unexpected T_STRING in C:\Documents and Settings\Dale Piper\Desktop\Xampp\htdocs\Download.php on line 2

    Code:
    <?php// It will be called downloaded.pdf
    header('Content-Disposition: attachment; filename="Upload/1.mp3"');
    ?>

  • #7
    Senior Coder
    Join Date
    Jan 2007
    Posts
    1,648
    Thanks
    1
    Thanked 58 Times in 54 Posts
    Exactly. Do some more basic PHP before you just ask for code snippets. Have you tried anything yourself? Or are you just copying scripts and changing numbers?

  • #8
    Banned
    Join Date
    Oct 2007
    Posts
    52
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Why Doesn't This Work?

    The following code displays a download dialog box, but offers to download/save the php file, not the mp3. How do I download the mp3 file?

    Code:
    <?php
    header('Content-Type: application/force-download; filename="Upload/1.mp3');
    ?>

  • #9
    Senior Coder
    Join Date
    Jan 2007
    Posts
    1,648
    Thanks
    1
    Thanked 58 Times in 54 Posts
    Header does one thing, it tells the browser something. It doesn't modify what you output.

    This is what you need to do (in psuedo code):

    Code:
    tell browser to expect an mp3
    tell browser to show user a file download box
    output mp3 contents

  • #10
    Banned
    Join Date
    Oct 2007
    Posts
    52
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I know that, but how?

  • #11
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,642
    Thanks
    2
    Thanked 405 Times in 397 Posts
    Lookup the "Content-type" header.


  •  

    Posting Permissions

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