Jump to content

Beginner problem: Trying to file_get_contents of file that force-downloads


yortzec

Recommended Posts

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

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.

"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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.