PHP help?

Discussion in 'OT Technology' started by o2, Apr 6, 2007.

  1. o2

    o2 Witty Title Here OT Supporter

    Joined:
    Oct 4, 2005
    Messages:
    16,099
    Likes Received:
    11
    Location:
    Toronto
    Im adding a download link to one of my sites, which allows the user to download a video file off the server (and tracks the clicks). The problem is that vidoe files start playing in the browser instead of downloading. Is there a way that I can force the "save target as" command with php?
     
  2. crazybenf

    crazybenf Active Member

    Joined:
    Nov 14, 2001
    Messages:
    15,575
    Likes Received:
    2
    set the mime type in the header.


    header("Content-Type: application/x-octet-stream");
    header("Content-Disposition: attachment;filename=blah.blah");
    readfile("blah.blah");
     
  3. P07r0457

    P07r0457 New Member

    Joined:
    Sep 20, 2004
    Messages:
    28,491
    Likes Received:
    0
    Location:
    Southern Oregon
    there's no guarantee that'll work, but I guess it's better than nothing.
     
  4. o2

    o2 Witty Title Here OT Supporter

    Joined:
    Oct 4, 2005
    Messages:
    16,099
    Likes Received:
    11
    Location:
    Toronto
    The filename isn't local, its getting it from a remote server.
     
  5. P07r0457

    P07r0457 New Member

    Joined:
    Sep 20, 2004
    Messages:
    28,491
    Likes Received:
    0
    Location:
    Southern Oregon
    if you're serving remotely over HTTP, I'm not aware of a way to do this... You'd have to stream it to your server, and re-send it to the client (doubling bandwidth usage) and eating CPU. Not worth it, imo.
     
  6. o2

    o2 Witty Title Here OT Supporter

    Joined:
    Oct 4, 2005
    Messages:
    16,099
    Likes Received:
    11
    Location:
    Toronto
    Arrrr okay thanks.
     

Share This Page