How to know the file type of the file which you are forcing the user to download?

Posted by Starx on Stack Overflow See other posts from Stack Overflow or by Starx
Published on 2010-05-25T07:54:41Z Indexed on 2010/05/25 8:01 UTC
Read the original article Hit count: 175

Filed under:
|

I am trying to force the user to download a file. For that my script is:

$file = "file\this.zip";        
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-Disposition: attachment; filename=$file");
header("Content-Type: application/zip"); //This is what I need
header("Content-Transfer-Encoding: binary");
readfile($file);

The files I am going to upload my not be .zip all the time so I want to know the content type of the image I am going to receive in $file. How to accomplish this

© Stack Overflow or respective owner

Related posts about php

Related posts about file-handling