Web Hosting Talk







View Full Version : file opens in desktop program


mjfroggy
03-19-2006, 05:10 PM
Hello,

I thought this could be done but maybe not?

What I have is a php script that lists all the files in a folder on my server which is a lunix server if that matters. Some of these files are powerpoint files some are MSWORD files (this is a document managment system). What I want is when I click the link to have the file load in the correct desktop program as opposed to have it be opeing in the IE browser. Is their anyway when I click the .doc file to have it know to open in msword instead of have it open in IE?

I tried the below code with no luck but maybe I am doing it wrong?

if ($handle = opendir('.')) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != ".." && $file != "index.php" ) {
echo "<a href='$file' mime-type: mime_content_type('$file')>$file</a><br>";
}
}
closedir($handle);
}


Any suggestions???
thanks

mitchlrm
03-20-2006, 01:14 AM
FireFox uses mime types and file extensions in a fairly rational way, so that you could have a file opened by a "helper application" like MS Word, instead of the browser. IE will ignore mime types and open a file based on what it thinks is correct...