dcsimg
www.webdeveloper.com
Results 1 to 2 of 2

Thread: Problem with a PHP force download script

  1. #1
    Join Date
    Apr 2008
    Posts
    139

    Problem with a PHP force download script

    I pasted a copy of a code that someone shared on this site for forcing downloads. I tested out for downloading mp3 files. When you click on the link for calling the php code it does prompt you and asks if you want to open or save the file. The file type shows as "mp3" however the file size says 221 bytes. I know that the file is about 20MB.

    If I click on Save, it prompts me to save to my local hard drive. The "Save as Type" shows up, by default, as HTML document. Why would it do that? This is an mp3 file. Even if I change it to "All Files" and save it as an mp3, it doesn't play. I get an error saying it doesn't recognize the file.

    Anyone one have a diagnosis?

    CODE<?php
    ini_set('session.cache_limiter', '');
    header('Expires: Thu, 19 Nov 1981 08:52:00 GMT');
    header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
    header('Pragma: no-cache');

    header("Content-Disposition: disposition-type=attachment; filename=movie.wmv");

    readfile("http://www.remotedomain.com/movie.wmv");
    <!-- the movie,mp3,mpeg file can be sitting on a remote domain and you just call to it. -->
    ?>

    Code for the calling link:
    CODE<html>
    <head>
    <title>Testing Movie Download</title>
    </head>

    <body>

    <a href="/path/to/script.php">Download Movie</a>
    <!-- Where script.php is stored on your domain -->

    </body>
    </html>

  2. #2
    Join Date
    Apr 2017
    Posts
    1
    How Can I force mp3 Download on my Music Website

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles