Results 1 to 8 of 8

Thread: left click to save as

  1. #1
    Join Date
    Jul 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post left click to save as

    hi, my question is about the same as an existing post but I didn't understand it and I need help for another type of file.

    I have a mp3 website and when users search of a song, it simply crawls the web to find it from different sources. My download links are currently direct links to the mp3 song found so the users need to right click and "save link target as" to get the song. I would like users to be able to simply left click on the link to download.

    I googled and found a php script that may help me but i don't understand how to implement it (I'm new to php) here is the link.

    So please help me find a way to download mp3's with a left click, thank you.

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    This is complex.
    The browser decides what to do with a file. The only way to get the browser to download instead of viewing (since it's basically the same behavior, based on what the browser thinks it should do) is to trick the browser into thinking it's another kind of file.
    So you use a different header and the browser thinks it can't play it, etc.

    One guaranteed way is to offer your mp3s within zip files. Then the user must download that and extract it, and it saves bandwidth. It's one more step for the user, but that guarantees they can't play it.

    Basically you can look for several ways to fake the filetype but it won't be easy or work in all browsers.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Oct 2009
    Posts
    845
    Thanks
    14
    Thanked 189 Times in 188 Posts

    Default

    Hi imSOmusic ! To my big surprise it actually works the script you are linking to.
    I made a quick test of it and you can see it HERE. Sorry this link and the files on my server are removed for security reasons
    To make it easier for you to implement I have attached a zip folder. You can download and unzip it and see how the files are made. I put a silly picture instad of the mp3 to make it smaller in size to upload. Of course you would have to replace the link url's with your own. I don't know much about php so i can't really explain it, but it seems to work !!

    edit; It works in ff as expected. Ie gives the usual download warnings. Chrome downloads the file without having to confirm. Haven't tried safari and opera yet.

    edit 2: I don't recommend using script before investigating if it is secure to have on your server. I removed it from my server.
    Last edited by azoomer; 07-11-2010 at 07:44 PM. Reason: the download.php file seemed a little insecure.

  4. #4
    Join Date
    Jul 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    nice but my sources are from other servers.. (I'm just a music search engine but with direct links to "play" and "download" the songs)

    my download links are like that:
    HTML Code:
    <body bgcolor="#FFFFFF">
    <div align="center" style="width:100%;">
    <?php
    
    $download = $_GET['url'];
    
    ?>
    
    <a href="<$download;?>">Download</a>
    
    </div>
    </body>
    so how can I integrate the download.php ?

  5. #5
    Join Date
    Oct 2009
    Posts
    845
    Thanks
    14
    Thanked 189 Times in 188 Posts

    Default

    I guess this script works if the download.php is on the same server as the file that should be downloaded. Can't see how it should work on a remote server, but what do I know ?

  6. #6
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    two problems:

    1) the browser (them), not the server (you) decides whether to download something or open it by default.

    2) since the songs aren't yours, you have no control over how they are presented to the browser.

    Sorry to say it, but you're basically "out of luck" - twice.

  7. #7
    Join Date
    Jul 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    thanks anyway guys! you where very useful (if it had worked)

    I'll simply keep telling my visitors to right click and save ..

  8. #8
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    depending on how complex you want to make things (and copyright issues, of course), you could develop a script that downloads the selected file to your server when clicked, (optionally) zips it, and then offers it to the user for download. This would also take longer - there would be a noticeable pause - but you could also cache the file, so popular songs wouldn't have to be downloaded repeatedly. But I suspect this is beyond what you want to do, and, as I mentioned, it could spiral into a terrible copyright mess.

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
  •