Welcome Guest, Not a member yet? Register   Sign In
forced download problem
#1

[eluser]jon29[/eluser]
hi have a site with download section using force download helper, works 100% fine on local sever uploaded it to sever and now when attempt to download it runs this error


A PHP Error was encountered
Severity: Warning
Message: file_get_contents(http://79.170.40.38/sucatarallytest.com//files/example.jpg) [function.file-get-contents]: failed to open stream: Connection refused
Filename: models/data_model.php
Line Number: 213

permissions set sames as other images folders

driving me mad, any ideas on what it could be??
#2

[eluser]Stefan Hueg[/eluser]
Hi,
could you post more code from your model? It looks like if you're trying to download a remote file and send it right away to the browser. More info please.
#3

[eluser]jon29[/eluser]
hi thanks

this is the code that i use with download helper in order to force download, I think the problem is that the sever I use doesn't allow the file_get_contents to work due to security settings is there an alternative way to get the required data??

Code:
public function download_file ()
{
$this->load->helper('download');
  $data1 = file_get_contents(site_url() . "/files/" . $this->uri->segment(3)); // Read the file's contents
  $name = $this->uri->segment(3);
  force_download($name, $data1);
}
#4

[eluser]CroNiX[/eluser]
Check the docs for file_get_contents(). The server HAS to have fopen wrappers enabled (disabled on a lot of servers) in order to use a URL as the file location. You can always use a real file path though.
#5

[eluser]jon29[/eluser]
thanks,
yeah spoke to server provider and its disabled, can't be changed,
what could i do instead??
#6

[eluser]CroNiX[/eluser]
If its local use the real filepath. If its remote, you can try using curl if that's enabled.
#7

[eluser]skunkbad[/eluser]
Perhaps I am just ignorant, but why can't you just use an anchor to the file's URL?
#8

[eluser]Stefan Hueg[/eluser]
[quote author="skunkbad" date="1335655314"]Perhaps I am just ignorant, but why can't you just use an anchor to the file's URL?[/quote]

Forced downloads, so that it's not embedded in your browser. Or to hide the original location of the files.




Theme © iAndrew 2016 - Forum software by © MyBB