Nov 22, 2009
Pages: 1, 2

Download Script

free web hosting
Open Discussion > MODERATED AREA > Computers > Programming Languages > Others

Download Script

bthaxor
hey all,

on my website, i would to link to files that i have created/found. since these files are larger than 5mb, and i didn't want to waste my precious 500mb space, i hosted them on fileden, an online file storage site allowing hotlinking. an example of a url from this site is:

http://www.fileden.com/files/2007/10/20/15...some%20file.mp3

so anyway, on one of my pages i would like to have a link to one of these files. however, instead of streaming the file as the website would normally do for the mp3 extension, i would like to 'force' the save link as / save as dialog to appear.

i have thoroughly researched this, however all of the working solutions require the php file to be placed in the same directory as the other files, and with the random urls that fileden generates that is not possible. otherwise, they use the $filename attriibute, which uses relative urls (e.g. ../../some file.mp3), which is also not possible in this case.

the javascript solution, which works, is not firefox compatible, and since i always use firefox and am a large fan of it, i find that frustrating.

for webdesign i use xhtml+css, and do not know php. which is why i need help, since most/all of the working solutions seemed to use php.

so, my question/request: any code which is incorporateable into a html page and takes into consideration my lack of php knowledge, which forces a 'save link as/save as' dialog to appear once the user clicks on a link, and is cross-browser.

thanks so much if you are able to help.

also, one last thing: if possible, i would like this code to be php/javascript, because they are the easiest to incorporate into html. NO ASP PLEASE!!!

Notice from rvalkass:

Merged double post.

 

 

 


Comment/Reply (w/o sign-up)

imbibe
could u post the javascript solution. someone might be able to port it to FF.
And according to Trap17 rules do not make double posts. edit your original one.

Comment/Reply (w/o sign-up)

bthaxor
the javascript code (only for ie) is:

CODE
<a href="java script:void(0);" onclick="document.execCommand('SaveAs',true,'http://fileden.com/somefolder/some file.mp3');">download</a>


and sorry about the double post, it is merged.

Comment/Reply (w/o sign-up)

alex7h3pr0gr4m3r
I think the best solution is to zip it. That way all browsers will be forced to download it, but why are you forcing people to download this song? I like to listen to mp3's streaming in my browser.

Comment/Reply (w/o sign-up)

bthaxor
i would like to force the download because that is exactly what the link is supposed to be: a download. i have asked people if they stream their music, believe me, and NO-ONE did.

also, i really wouldn't like to resort to a zip file! that's taking the easy way out... besides, i have already uploaded all my files as mp3's, you have no idea how long that took.

one last thing: i can't tell them to right click -> save link as even if i wanted to, because i have a script which disables the right click and is cross browser (at least it stops n00bs from viewing my source... all those who don't know how to user the menu bar).

the best approach to this would most likely be a download.php, however as mentioned before i do not know php, and the scripts that are available on the net have so far all required that the php file be placed in the same directory as the files, which is not possible in this case.

i have also heard something about content disposition headers... how do they work?

Comment/Reply (w/o sign-up)

iGuest-DiSaSteR MaSteR
Why not simply use PHP
Download Script

Replying to bthaxor
Just make the link to the mp3 file and use a force download php script
<?
// Tells the browser that where going to run a PHP script.
$file = $_GET['file'];
// Get a filename from the GET parameters.
Header ("Content-type: octet/stream");
Header ("Content-disposition: attachment; filename=".$file.";");
Header("Content-Length: ".Filesize($file));
// Sends the brower headers to tell it that its sending that file back to it.
Readfile($file);
// Reads the file from the server and send it to the browser.
Exit;
?>
// Closes the PHP script.

Call it forcedownload.Php
Then your link would be

<a href="http://www.Sitelocation/mp3s/forcedownload.Php?file=download.Mp3">Song Name</a>

Place the file forcedownload.Php in the directory with the mp3's

You can use this for any file extension.



-reply by DiSaSteR MaSteR

 

 

 


Comment/Reply (w/o sign-up)

andresf91
I would suggest you to allow your visitors to right click, it's so frustrating when you can't click as you wish, and when web developers interfere into my GUI.
I just leave the site!
Also, newbies are no harm if they sneak into your source code. The problems don't come from them. The problems come from those who already know how to use the menu bar, or better, how to disallow all Javascript.
So, if someone wants to find security leaks or steal your "precious HTML coding", use other ways.

Anyway, back to the topic, the best solution if you still refuse to allow your visitors to use their left button, use PHP, which doesn't require the file to be in the same directory as the mp3 file to download.
The code written by iGuest will work. Copy it from the opening <? to the ending ?>.

(But please delete the script that disallow the left click!)

Comment/Reply (w/o sign-up)

rpgsearcherz
I agree with andres. Allow them to right click on the links, and then they can choose to "Save As" or they can click it normally and stream it if they wish. This helps both groups of people(those who wish to stream and those who don't) and allows them more freedom.

To do that, it would be best to just add the text "Right click > Save As..." after it, plain text. This will help them out a little, for those who haven't ever had to use that method before.

Comment/Reply (w/o sign-up)

SofiaComp
QUOTE
Just make the link to the mp3 file and use a force download php script
<?
// Tells the browser that where going to run a PHP script.
$file = $_GET['file'];
// Get a filename from the GET parameters.
Header ("Content-type: octet/stream");
Header ("Content-disposition: attachment; filename=".$file.";");
Header("Content-Length: ".Filesize($file));
// Sends the brower headers to tell it that its sending that file back to it.
Readfile($file);
// Reads the file from the server and send it to the browser.
Exit;
?>
// Closes the PHP script.

Call it forcedownload.Php
Then your link would be

<a href="http://www.Sitelocation/mp3s/forcedownload.Php?file=download.Mp3">Song Name</a>

Place the file forcedownload.Php in the directory with the mp3's

You can use this for any file extension.


Yes, that's the thing try using php's integrated function header(); check that function in php.net, check the mime types that you need, integrate it in your webpage.

Comment/Reply (w/o sign-up)

(G)rasheed
How to pass a value to an exe on download
Download Script

Hi,

I want to  know how to pass say example UID to an exe /  App  as param while downloading from php header

 Will really  appreciate the Response.

-reply by rasheed

Comment/Reply (w/o sign-up)



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

This textarea will convert to Rich-Text automatically (IE, Firefox, Chrome)

Pages: 1, 2
Similar Topics

Keywords : download, script

  1. Seeking Help With Javascript
    Need help with drag and drop type script (1)
  2. Browser Compatibility Problem With Firefox - Javascript + Css
    Having trouble making a script work right - any suggestions? (3)
    Hi, Im working on a website, and im trying to make a right-click menu, which opens on right click,
    wherever the cursor is, and closes on mouse out. I wrote the code below, and when i ran it in IE it
    ran fine, just how i wanted it to work. However in firefox, the menu just opened in the top left. im
    presuming this is because it doesnt like my style changing in the javascript. Any ideas, and
    suggestions? If i cant make this work, i will just make it so it works slightly differently when
    viewev in firefox so that it can just open in one place. All ideas appreciated. ....
  3. Streaming Video Capture On Linux
    this script will download all the stream video using linux mplayer (2)
    i was looking for video capter on linux and i coldent find one so i rote one of my one if you use
    linux then you can try this script and if you need any hep just ask CODE #!/bin/bash #      
    # mplayer auto dump stream script #this script will download all the stream files in the ./zam_list
    files #this script by (mohammed tawfeek) zamaliphe@gmail.com #i have do this to be able to watch
    the video on Linux #if you think it is illegally or some thing just  don't tel me that ha #©
    #bash 6/6/2006 download_folder="./video/" #grep -e HREF ./asx/*.asx > ./list1.tx....
  4. Lightbox Script Variations
    (0)
    When the Web 2.0 and Ajax era kicked the best of the best in programmers started creating scripts of
    various kinds. One of these scripts called Lightbox has one of the biggest impact I have notice, it
    is well customizable to fit various formats, such as images, videos, and even maps. To start off I
    will post a link to the original source of the script, I think. Lightbox The object of this
    script is simple, when a user clicks on a thumbnail version of an image it does smooth transition of
    a pop up image that is larger, usually the original size, and when the user cl....
  5. Ajax - A New Technology
    AJAX relies on Java Script (10)
    Recently i did one of my project using AJAX and i could experience the real advantage of this
    Language , What do you say about that ?....
  6. How Can I Make An Auto-updating Shoutbox Type Script?
    I have a few ideas involving AJAX but im looking for something more.. (9)
    Hi all. Ive just started to experiment with AJAX working with PHP and MYSQL to get data and display
    it and im looking to implement it into a shoutbox similar to the one here on the forums but i have a
    question... i know how to use ajax and JS to refresh the contents of a DIV every few seconds r so
    and that essentially reloads the shoutbox content as the REFRESH button does up there ^^ on the
    shoutbox but i think it silly that it should update every few seconds even if theres no new activity
    so what im looking for is a way of letting my AJAX know when there is a new ent....
  7. Looking For Phpbb Script
    (2)
    Hi Friends, I am new to this phpbb script, I come across some features in some site... In some
    sites, the user should reply to the post to view the hidden content. ... Where can I find this kind
    of scripts or plug-ins... Please reply me in this thread.......
  8. Swf Cd Help Needed Please
    Need assistance with a next/previous page script (1)
    Question is: I have a web page that displays a flash file that zooms and pans, but the next page
    button doesnt work. 1. Can the next page work and load the next or previous numbered file? 2. Does
    it have to have all pages in one file, then it calls the next frame? I can e-mail you the 3
    pages/files directly, firewall wont let me pload them. Thank you....
  9. How Do I Script A Tutorial Submit Site
    (3)
    I am very interested in learning how to create or start my own tutorial submitt site. What do I
    need to learn ? What do I need to have. Is there a script that can be made up or a software? What
    I would like to do is start my own tutorial submit site. something similar to good-tutorials and or
    pixel2life except those sites are really big and cover many tutoriasl for many different programs.
    Id like to just cover tutorials for maybe a total of 3 to 4 different programs. Im sure I need
    hosting a domain a site and some good forums to get something good going. But t....
  10. Error In Purchased Script
    Help Me? (9)
    Ok well i bought a script off the net and tried uploading it to my server and it gave me this error
    Fatal error: Unable to read 22293 bytes in /home/ancient/public_html/index.php on line 0 so i
    contacted the guy who made the script and he said there was nothing wrong with the script and gave
    me a ftp to his account and told me to upload the it there and it works on there so i tried another
    script from another guy and i get same error you guys know anything about it???? Moving from
    Computinghost > Technical Support to Programming. Edited topic title--"Help with a scr....
  11. Need Script Please
    need script (4)
    Hey everyone i need a script for a password protected page but not just that i also want and
    registration form with it can n e help....
  12. What Is A News Script?
    Fusion News? Cute News? (1)
    What do news scripts such as Fusion News and Cute News do? Does it provide local news or global
    news or something? Or is it something else?....

    1. Looking for download, script

Searching Video's for download, script
See Also,
advertisement


Download Script

Affordable Web Hosting, Low cost Web Hosting - ComputingHost.com