#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2000
    Posts
    0
    Rep Power
    0
    Instead
    1)<a href="song.mp3"> Song </a>
    I am write
    2)<a href="song.php"> Song </a>

    What song.php must to do.
    Must no behaviour difference between 1 and 2
    for client.
    What i must to write in song.php so that
    browser begin start download "song.mp3"?
    song.php:
    -------------------------------------------
    <?php
    $file='song.exe';
    header("Content-type: application/octet-stream");
    header("Content-Disposition: attachment; filename=$file");
    header("Content-Transfer-Encoding: binary");
    ?>
    <?
    if (!readfile($file))
    die("can't read $file");
    ?>
    --------------------------------------------
    but it don't work right.
    All is normal, but size of downloaded file is wrong (some bytes)
    What i do wrong (php 4.03.pl1 ISAPI win2000 iis5)




    [This message has been edited by john07 (edited November 20, 2000).]
  2. #2
  3. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Brussels, Belgium
    Posts
    14,643
    Rep Power
    4492
    One way I can think of doing it is using a meta tag.

    Call the page like this: <a href="song.php?song_name=song.mp3">

    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
    ************
    * song.php *
    ************
    <html>
    <head>
    <meta http-equiv="Refresh" content="5,<? echo $song_name; ?>">
    </head>
    <body>
    Your song will begin downloading in a few seconds. Thank you. If it does not begin, <a href="songs/<? echo $song_name; ?>">click here.</a>
    </body>
    </html>
    [/code]

    You pass the name of the song you want to download and it'll start in 5 seconds after the page is loaded. That's what the 5 is in the meta tag. You can even have some php code in there to track which files are being downloaed, incrementing counters for each file, etc...

    Have fun.

    ---John Holmes...

    [This message has been edited by SepodatiCreations (edited November 19, 2000).]
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Location
    Melbourne, Victoria, Australia
    Posts
    104
    Rep Power
    15
    You could also get your php script to directly output the mp3 data using readfile or a similar method, although your file wouldn't download as whatever.mp3 - it would download as the name of your php script which isn't really too good.

    Hope that helps,

    Josh
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2000
    Posts
    0
    Rep Power
    0
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by #6:
    You could also get your php script to directly output the mp3 data using readfile or a similar method, although your file wouldn't download as whatever.mp3 - it would download as the name of your php script which isn't really too good.

    Hope that helps,

    Josh
    [/quote]
    i am write song.php:
    <?php
    $file='song.exe';
    header("Content-type: application/octet-stream");
    header("Content-Disposition: attachment; filename=$file");
    header("Content-Transfer-Encoding: binary");
    ?>

    <?
    if (!readfile($file))
    die("can't read $file");
    ?>

    but it don't work right.
    All is normal, but size of downloaded file is wrong (some bytes)
    What i do wrong (php 4.03.pl1 ISAPI win2000 iis5)
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2000
    Posts
    0
    Rep Power
    0
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by SepodatiCreations:
    One way I can think of doing it is using a meta tag.
    ......................

    Have fun.

    ---John Holmes...

    [This message has been edited by SepodatiCreations (edited November 19, 2000).]
    [/quote]

    It's don't work.
    page refreshed each 5 s, but "File Download" dialog don't called.
    <meta http-equiv="Refresh" content="5,file">
    what mean of file here?

  10. #6
  11. No Profile Picture
    Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2000
    Posts
    6
    Rep Power
    0
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by john07:

    <meta http-equiv="Refresh" content="5,file">
    what mean of file here?

    [/quote]

    Im not sure i understand the question, but i think this is the answer :-)

    file is the path where the mp3 song is located!
    if your song.mp3 is located in a directory songs then file would be: http://www.yourdomain.com/songs/song.mp3 or just song/song.mp3



    ------------------
    Until next time, I'll Remain!!
    Quote the Dokus:"NeverMore!"
  12. #7
  13. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2000
    Posts
    0
    Rep Power
    0
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by Dokus:
    Im not sure i understand the question, but i think this is the answer :-)

    file is the path where the mp3 song is located!
    if your song.mp3 is located in a directory songs then file would be: http://www.yourdomain.com/songs/song.mp3 or just song/song.mp3


    [/quote]
    I have found the rigth aswer.
    Instead
    <meta http-equiv="Refresh" content="5,file">
    I must write
    echo "<meta http-equiv='Refresh' content='$delay;url=$url'>";
    It's really work.

    Thank you to all for help.



    [This message has been edited by john07 (edited November 21, 2000).]

IMN logo majestic logo threadwatch logo seochat tools logo