yortzec Posted June 10, 2012 Share Posted June 10, 2012 I am trying to get the contents of a file on an external website (the file is http://sync.in/ep/pad/export/c9ppXi1bp7/latest?format=txt), but it fails, I think because the server force-downloads the file. Is there any way to fix this or go around this? I receive the following error: Warning: file_get_contents(http://sync.in/ep/pad/export/c9ppXi1bp7/latest?format=txt) [function.file-get-contents]: failed to open stream: Connection refused Thanks for any help, Y Link to comment https://forums.phpfreaks.com/topic/263958-beginner-problem-trying-to-file_get_contents-of-file-that-force-downloads/ Share on other sites More sharing options...
requinix Posted June 10, 2012 Share Posted June 10, 2012 file_get_contents() is enough. Apparently the sync.in server is refusing your connection to download the file. Or maybe your PHP configuration disallows downloading files but I think you'd get a different error message for that. I just tried echo file_get_contents("http://sync.in/ep/pad/export/c9ppXi1bp7/latest?format=txt"); and it worked for me. Link to comment https://forums.phpfreaks.com/topic/263958-beginner-problem-trying-to-file_get_contents-of-file-that-force-downloads/#findComment-1352740 Share on other sites More sharing options...
.josh Posted June 10, 2012 Share Posted June 10, 2012 "force downloads" is a browser thing. It is a http header sent with the response to tell the browser to initiate download. It means absolutely nothing to server-side scripting unless you write your script to look for it and do something. Same thing w/ browsers, actually...just that browsers ARE written to look for it and do something. Link to comment https://forums.phpfreaks.com/topic/263958-beginner-problem-trying-to-file_get_contents-of-file-that-force-downloads/#findComment-1352775 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.