Would somebody could tell me how to force download in IE? I saw someone did a code (as shown below) and I 've tested it works in Netscape but does not work in IE, so I added some changes on it, but still can;t work in IE! Could sone of you kindly to show me why and how to fix it!
// downloading a file
$filename = $HTTP_GET_VARS['path'];
// fix for IE catching or PHP bug issue
header("Expires: 0"); // set expiration time
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
// browser must download file from server instead of cache
// force download dialog
// use the Content-Disposition header to supply a recommended filename and
// force the browser to display the save dialog.
header("Content-Disposition: attachment; filename=".basename($filename).";");
The Content-transfer-encoding header should be binary, since the file will be read
directly from the disk and the raw bytes passed to the downloading computer.
The Content-length header is useful to set for downloads. The browser will be able to
show a progress meter as a file downloads. The content-lenght can be determines by
filesize function returns the size of a file.
This is maybe an old topic, but i'm really really desperate in trying to get it work.
Because i copy and pasted the code above exactly and it doesn't work
I really tried about 20 'force download scripts' and none has worked so far...
But i'm hopefull because at least with this script, i already get a download window, where i can choose if i want to save or open the file, but the problem is that php doesn't find the file, because the download window syas that the size of my jpeg is about 500 bytes, which is way too less of course!
I think it could have something to do with permissions?? Because the php script is in a different directory then the actual picture.
Can anybody help me please because i've really been looking for a solution for this force download thing for days and days if i add all the hours.....
thanks for your reply.
all the permissions are set to 755, so i don't think that could be the problem.
I have been digging into this problem the last few hours and this is what i discovered :
appearantly the problem is that the 'readfile' function, doesn't have permission to read the pic that i want , 'open_basedir restriction in effect'
I've been looking on the php.net site and i found that the problem might be that the openbase directory is put to the wrong value (i've checked this for my ISP and its value is something with 'temp', so definitely not the directory where my pictures are)
So i think that's why it won't work
The solution would be that i have all my pictures in the same directory as this php script, but unfortunately i can't do that.
So i wrote an email to my ISP to ask if and how i can adjust this php.ini file (because appearently it depends from ISP to ISP), so that i can change the openbase dir.