i want to create a page that let the user download mpg file, but i don't know how to do it , i look in html form tutorial but i found nothing, i also read some of the site source that let the user download software but it always run the movie not let the user choose the place where to download it

plz reply soon
plz

    <?php
    header("Content-type: application/octet-stream");
    header("Content-Disposition: attachment; filename=somefilename");
    readfile('fullpathtofilename");
    ?>

      i don't know where to place it, i put the code that you give me in a code just to see how it work but i display me a funny symoble

      what i realy want to do is that the user can see the page that contain the link and a message is displayed telling him to choose the place where to save the file

        first.php

        Suppose we have a link in first.php like below

        <a href="download.php?filename=xyz.mpg">Download</a>

        download.php

        Suppose xyz.mpg is in /var/www/upload/

        then in download.php

        <?php

        header("Content-type: application/octet-stream");
        header("Content-Disposition: attachment; filename=".$GET['filename']);
        readfile("/var/www/upload/".$
        GET['filename']);
        ?>

        this will let u download the file

          thanks it work but i have anther problem

          the problem is that not all movie allocated in the same directory
          i kind of save the directory name with the name of the file that i want the user to be downloaded,

          how can i send the directory name to the download page without using a session coz my page have already a header ,
          and is there a way to send it with the file name and then use the Get ??????

            You can pass the path like below:
            <a href="download.php?filename=xyz.mpg&path=/var/www/upload/">Download</a>

            or u can store all file information(filename,filepath etc etc) in table in database.
            and on download page fetch the information of path depending on filename.

              Write a Reply...