Problem with my file download code.... Please Help me!!
Posted: Thu Sep 04, 2003 8:46 am
Hello,
I have written a script to upload file from browser, thats working fine, but I am having lot of problems with my file download code in difference browsers. What I want is the file dialog box that popsup when I click to download a file, I want an "Open" file option also along with the "Save" file option in any of the browsers, which I am not getting. I am pasting my file download code here and also the possible error message that my client is getting. The worst thing is its working from my side but not from the clients side.. Please help this is very critical for my project
Here is the file download code:
header("Content-Type: application/octet-stream;");
header("Content-Disposition: attachment; filename=$row[FileName]");
header("Pragma: no-cache");
header("Expires: 0");
if(file_exists($path.$row[FileName]))
{
$fp=fopen($path.$row[FileName],"rb");
while(!feof($fp))
{
$fcontents=fread($fp,4096);
echo $fcontents;
}
fclose($fp);
}
values in $path and $row[FileName] are correct.
Here is the clients list of error messages:
1. For MS Word Document, I got "This file can not be found. Try one or more of the following: *Check spelling of the name of the document and *Try difference file name."
2. For PowerPoint File, I got: "The path or file name for c:\Documents and Setting\tan lam\local setting\temporary Internet files\Content .IE5\G… is not valid. Please check the path and file name are correct.
3. For Flash File: I got Flash Player Open with blank page.
4. For Window Media File, I got "WM Player cannot fine the specified file. Be sure the path is type correctly. If it is , the file does not exist at the specified location, or the computer where the file is stored offline.
I have written a script to upload file from browser, thats working fine, but I am having lot of problems with my file download code in difference browsers. What I want is the file dialog box that popsup when I click to download a file, I want an "Open" file option also along with the "Save" file option in any of the browsers, which I am not getting. I am pasting my file download code here and also the possible error message that my client is getting. The worst thing is its working from my side but not from the clients side.. Please help this is very critical for my project
Here is the file download code:
header("Content-Type: application/octet-stream;");
header("Content-Disposition: attachment; filename=$row[FileName]");
header("Pragma: no-cache");
header("Expires: 0");
if(file_exists($path.$row[FileName]))
{
$fp=fopen($path.$row[FileName],"rb");
while(!feof($fp))
{
$fcontents=fread($fp,4096);
echo $fcontents;
}
fclose($fp);
}
values in $path and $row[FileName] are correct.
Here is the clients list of error messages:
1. For MS Word Document, I got "This file can not be found. Try one or more of the following: *Check spelling of the name of the document and *Try difference file name."
2. For PowerPoint File, I got: "The path or file name for c:\Documents and Setting\tan lam\local setting\temporary Internet files\Content .IE5\G… is not valid. Please check the path and file name are correct.
3. For Flash File: I got Flash Player Open with blank page.
4. For Window Media File, I got "WM Player cannot fine the specified file. Be sure the path is type correctly. If it is , the file does not exist at the specified location, or the computer where the file is stored offline.