I'm working on a download counter script and I'm having a bit of trouble with the

header('Content-Disposition: attachment; filename="filename.mp3"');

... portion of my code.

that completely makes sense to me, but in my database, the entire URL is stored (ex. "http://www.mydomain.com/mp3/thisisa-filename.mp3")

... is there any way to split "thisisa-filename.mp3" from the rest of the URL? The files will be located on different servers, so I can't just trim off the first 28 characters every time and be left with the file name

any ideas on how i could pull the filename from the URL?

    you could do

    substr(strrchr($fileloc, "/"), 1);

    btw, i made a download counter, feel free to reference it and 'borrow' any code you want.

    www.drew-phillips.com/scripts/
    but they are different because mine only allows you to download from one folder for security reasons.

      It puts that as a full url because you are using header: and so php assumes that it is on the server. You need to put the real FULL URL not just filename.

        Write a Reply...