hi,

i have to download file from my site.
m using code:

$file1=$_POST['file_name'];

header("Content-type: application/mp3/mov/avi/text/plain");
header("Content-Disposition: attachment; filename=".$file1);
readfile($file1);

vaery first time m downloading only videofile.
they work well.

but wen i add for textfiel,documentfile,pdf etc.

it not working.

it download file but not actual content. it wrote with my code.

give me sample code for multiple filetype dowload.

if possible give sample code,

help me to sortout

Thanx

    Well this line is meaningless:

    header("Content-type: application/mp3/mov/avi/text/plain");

    You're supposed to specify the type of file you're serving, not just mindlessly throw everything in there.

      You can use the fileinfo functions ([man]finfo-file[/man]) to get the correct MIME-type for the file that you are serving to the browser, and use this in the Content-Type header.

      OR use [man]mime_content_type/man but that has been deprecated for the above function. Hope this helps.

        Or "application/octet-stream" might be applicable for a wide range of files.

          Hi,

          thanks for reply

          i m doing cart.
          were i have Book and Audio type

          files are uploaded ok,

          but at downlaod i have problem

          wen the product is of book then downlaodabel is pdf or doc fiel

          n wen it s audio downlaodable mov,.avi,.mp3, or ny video or audio clip

          so wat to do ?

          help me

            Write a Reply...