Forum Moderators: coopster

Message Too Old, No Replies

downloading files with php

how to avoid the "file download" alert

         

mista_phi

1:42 am on Oct 7, 2004 (gmt 0)

10+ Year Member



I'm using the following code so users can download file from my site:

=====================================================

function DownloadFile($file)
{

if (file_exists($file))
{
$filesize = @filesize($file);
header('Content-Disposition: attachment; filename="' . $file . '"');
readfile($file);
return;
}
}

DownloadFile("filename");

=====================================================

Before the file begins to download, the user is prompted with a "File Download" alert that reads:

Some files can harm your computer. If the file information looks suspicious, or you do not fully trust the source, do not open or save this file.

Then it asks if the user wants to open the file or save it to their computer, providing 4 buttons: Open, Save, Cancel, More Info.

Are there any parameters that I can set in my program to stop this alert from popping up?

Thanks

Adrian2k4

1:44 am on Oct 7, 2004 (gmt 0)

10+ Year Member



there is no way you can influence this dialog box in any way, nither with php nor with any other language.
it is the browser that decides how to handle file downloads.
you will find that the dialog box is different depending on which browser you use.

mista_phi

1:50 am on Oct 7, 2004 (gmt 0)

10+ Year Member



thanks