|
|
|
||||
|
Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact us. |
![]() |
|
|||||||
| Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed. |
|
|
Thread Tools |
|
|
#1 |
|
Confirmed User
Join Date: Apr 2004
Location: Montreal
Posts: 799
|
I'm using this function to send a file to my users :
function send_file($name) { ob_end_clean(); $path = $name; if (!is_file($path) or connection_status()!=0) return(FALSE); header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); header("Expires: ".gmdate("D, d M Y H:i:s", mktime(date("H")+2, date("i"), date("s"), date("m"), date("d"), date("Y")))." GMT"); header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); header("Content-Type: application/octet-stream"); header("Content-Length: ".(string)(filesize($path))); header("Content-Disposition: inline; filename=$name"); header("Content-Transfer-Encoding: binary\n"); if ($file = fopen($path, 'rb')) { while(!feof($file) and (connection_status()= =0)) { print(fread($file, 1024*8)); ob_flush(); } fclose($file); } return((connection_status()= =0) and !connection_aborted()); } But for some reason if I try to open it without saving it on my disk it will causes an error. (Invalid Zip file) But if I save the file first and then open it everything works just fine. How can I fix that ?
__________________
I have nothing to advertise ... yet. |
|
|
|
|
|
#2 | |
|
So Fucking Banned
Join Date: Oct 2002
Location: MaxCash.com
Posts: 12,745
|
Quote:
Im not totally sure - but I think it could be the mime type setting in your apache config file that is the issue. That could be a start for you to Google from - but I could be way off. |
|
|
|
|
|
|
#3 | |
|
Sofa King Band
Join Date: Jul 2002
Location: Outside the box
Posts: 29,903
|
Quote:
header("Content-Type: application/zip"); A list of other content types can be found just over half way down the page here: http://www.expertsrt.com/tutorials/M...P_headers.html |
|
|
|
|
|
|
#4 |
|
Confirmed User
Join Date: Apr 2004
Location: Montreal
Posts: 799
|
Was a nice Idea but it doesn't works either :-(
__________________
I have nothing to advertise ... yet. |
|
|
|
|
|
#5 |
|
www.creationcrew.com
Industry Role:
Join Date: Feb 2005
Location: CREATIONCREW.COM CREATIONCREW.COM CREATIONCREW.COM CREATIONCREW.COM CREATIONCREW.COM CREATIONCREW.COM
Posts: 12,111
|
bump.....
__________________
![]() ++ Adult and Mainstream Websites Designs | 10 banners for only $50 | html5 Banners ++ email : [email protected] Telegram : https://t.me/creationcrew | HTML5/Responsive Site - Div/CSS - ElevatedX - NATs - Wordpress |
|
|
|
|
|
#6 |
|
Registered User
Industry Role:
Join Date: Mar 2006
Location: North Pole
Posts: 82
|
If I open a zip file when prompted by my browser during testing (rather than save it), it opens fine for me (using WinRAR as my archiver on my pc here). The same zip file also opens fine if I actually save it to disk when prompted by the browser. This is using Firefox v1.5.0.4. The code does not work properly at all for me in IE6, but rather gives a browser error after trying to send the page (whatever.php where your function is sitting) itself.
My guess is that your specific combination of headers used so as not to cache the file being downloaded are the problem for you. You're telling the browser not to cache a copy of the file, which is fine if you're saving it to disk locally. However, if you try and have the browser just open the file without having cached it, it will probably choke depending on browser behaviour. There are varying combinations of http headers you can use in your PHP scripts to avoid having files be cached on the local browser; some of them are browser specific (IE one way, most other browsers another way), so on past scripts i can remember doing a check for IE before sending appropriate headers for tools like yours. Read through the PHP documentation on headers for more info : http://ca3.php.net/header
__________________
rRhino.com ...social networking for book fans... |
|
|
|
|
|
#7 |
|
Confirmed User
Join Date: Apr 2004
Location: Montreal
Posts: 799
|
Your right ! it seems to works fine with FireFox.
It try a lot of cache-related header but I can't seem to get IE to works. I just don't get it !
__________________
I have nothing to advertise ... yet. |
|
|
|
|
|
#8 |
|
salad tossing sig guy
Join Date: Apr 2002
Location: mrthumbs*gmail.com
Posts: 11,702
|
why not a simple redirect to a physical file location?
|
|
|
|
|
|
#9 | |
|
Confirmed User
Join Date: Apr 2004
Location: Montreal
Posts: 799
|
Quote:
Impossible to do if you redirect to the file...
__________________
I have nothing to advertise ... yet. |
|
|
|
|
|
|
#10 |
|
Confirmed User
Join Date: Jun 2006
Location: Do you care?
Posts: 4,147
|
bump. php pro's time to step up!
__________________
|
|
|
|
|
|
#11 |
|
Confirmed User
Join Date: Apr 2004
Location: Montreal
Posts: 799
|
thanks for all the bump.
bump for myself :-)
__________________
I have nothing to advertise ... yet. |
|
|
|
|
|
#12 |
|
Confirmed User
Join Date: Apr 2004
Location: Montreal
Posts: 799
|
bump
5678
__________________
I have nothing to advertise ... yet. |
|
|
|
|
|
#13 |
|
Confirmed User
Join Date: Apr 2004
Location: Montreal
Posts: 799
|
Sorry to bump this an other time but I realy need a solution :-(
__________________
I have nothing to advertise ... yet. |
|
|
|
|
|
#14 | |
|
So Fucking Banned
Join Date: Oct 2002
Location: MaxCash.com
Posts: 12,745
|
Quote:
The more I think about it the I think that is the issue. If you dont have access to your Apache configs then try this in a .htaccess file AddType zip file zip |
|
|
|
|
|
|
#15 | |
|
Confirmed User
Join Date: Nov 2004
Location: scv
Posts: 2,299
|
Quote:
|
|
|
|
|
|
|
#16 |
|
Registered User
Industry Role:
Join Date: Mar 2006
Location: North Pole
Posts: 82
|
If you replace all of the header() lines you used with the following ones, it works correctly in IE6 and Firefox.
header('Cache-Control: '); header('Pragma: '); header("Content-Type: application/force-download"); header("Content-length: " . (string)(filesize($path))); header("Content-Disposition: attachment; filename=" . $path); Test it yourself and see how it works out for you.
__________________
rRhino.com ...social networking for book fans... |
|
|
|
|
|
#17 |
|
Confirmed User
Join Date: Apr 2004
Location: Montreal
Posts: 799
|
I don't understand why but it does works !!!
Thanks DuckDuckGoose.
__________________
I have nothing to advertise ... yet. |
|
|
|