I'm running a php site on localhost and i'm getting the following error.
Warning: file_get_contents(http://www.engadget.com/rss.xml)
[function.file-get-contents]: failed to open stream: HTTP request
failed! in C:\Program Files\xampp\htdocs\infohut\rss_read_class.php on
line 26
but when i run the same hosted in a real server, it doesn't give any error.
Also note that my local pc is connecting through a proxy and when i tried from a different pc with a direct connection to internet, the problem is not there.
So my guess is it has something to do with the proxy.
I'm using xampp for windows installation with php 5.1.4 and Apache 2.2.2
I tried adding my proxy settings to php.ini as well using below
pfpro.proxyaddress
pfpro.proxyport
still couldn't figure is out. Please advise if i need to change any other settings or anything.
Thanks
You should enable allow_url_fopen in your php.ini
Related
I am trying to get the size from an remote image with the native php function getimagesize from an absolute URL.
I am using PHP 7.3, here is the code:
$fichier = 'http://mydomain/images/image.jpg';
$size = getimagesize($fichier);
var_dump($size);
And the code return :
PHP Warning: getimagesize(http://mydomain/images/image.jpg): failed to open stream: Connection refused in ...
And with fopen, same problem:
PHP Warning: fopen(http://mydomain/images/image.jpg): failed to open stream: Connection refused
And when I am trying the same URL from an other server, it is working.
Also, if I am trying to get infos from an other image and from an other domain but on the same server, it is not working also.
allow_url_fopen is enabled.
I think that it should come from Apache conf, but not sure... Anybody has an idea ?
Thanks !
Finally, the problem is coming from the network.
Apache could not resolve his own public domain name.
So to correct the problem, I just had " 127.0.0.1 mydomain" in the hosts file, and the problem was solved.
Hope it can help !
Ive got a website where i want to open a file from another server. this server is connected using a network drive.
The file uses Windows authentication. Because of this, using
echo file_get_contents('\\\**.**.local/data/user/*/*.xlsx');
results in
file_get_contents(\\*.*.local/data/user/*/*.xlsx) [function.file-get-contents]: failed to open stream: Permission denied
I found a similar problem here:
How to use file_get_contents() to retrieve a file behind Windows NT Auth
But I cant get it to work. Using this:
getUrl('\\\*.*.local/data/user/*/*.xlsx','username','password');
Always results in :
Could not resolve host: \\*.*.local
Using
getUrl('file://*.*.local/data/user/*/*.xlsx','username','password');
gives me
Couldn't open file
/data/user//.xlsx
What am I doing wrong?
I think you can both use:
getUrl('file:////*.*.local/data/user/*/*.xlsx','username','password');
or
getUrl('file://\\*.*.local\data\user\*\*.xlsx','username','password');
I'm not one to normally reach out but I've found myself completely stumped by this one.
I have a new server and chose to go with Windows Server 2008 and Plesk. After importing my site, I find that my includes no longer work, coming up with this error message:
require_once(include/online_class.php) [function.require-once]: failed to open stream: Operation not permitted
Fatal error: require_once() [function.require]: Failed opening required 'include/online_class.php
I have disabled open_basedir to make sure that it isn't conflicting but I am still getting this message. I have tried doing a fresh install of PEAR via command line and have made sure include_path points to the correct directory -> C:\Program Files (x86)\Parallels\Plesk\Additional\PleskPHP5\PEAR
I have switched between both PHP 5.2 and 5.3 - 5.3 will just display a 500 error message without even reaching the php include errors.
Is there something I'm missing here? This is an issue I've never had with linux / cpanel builds and it's leaving a sour taste in my mouth with regards to Windows servers. What can I do to fix this problem?
Any help would be appreciated. Cheers!
I'm running a php in a unix shell and I'm getting the following error.
The script is a web scraper and it work fine on my host if I access it. But I want to run it as a cron job, What shoul I do?
Warning: file_get_contents(http://www.lomamatkat.fi/iframes/last-minute-offers/?lastminute_next=50): failed to open stream: no suitable wrapper could be found in /var/www/customers/lentovertailufi/public_html/matkat/script/lomamatkat.php on line 30
PHP Warning: file_get_contents(): URL file-access is disabled in the server configuration in /var/www/customers/lentovertailufi/public_html/matkat/script/lomamatkat.php on line 30
Update your php.ini file, and set the 'allow_url_fopen' option to 'On'.
If you are unable to change allow_url_fopen consider using use curl (if must be php) or Wget
go to the php.ini and enable that or use curl or one of the other http get functions. file_get_contents is considered a dangerous system call for urls because people can slip files into it as well.
I am using file_get_contents on my PHP and it throws some errors:
My code
#try to fetch from remote
$this->remotePath = "http://some-hostname.com/blah/blah.xml
$fileIn = #file_get_contents($this->remotePath);
The errors:
Warning: file_get_contents() [function.file-get-contents]: URL file-access is disabled in the server configuration in /virtual/path/to/file/outputFile.php on line 127
Warning: file_get_contents(https://some-host-name/data/inputFile.xml) [function.file-get-contents]: failed to open stream: no suitable wrapper could be found in /virtual/path/to/file/outputFile.php on line 127
Any idea? It worked fine in my computer but stopped working when I ported it to the web server.
Your server must have the allow_url_fopen property set to true. Being on a free webhost explains it, as it's usually disabled to prevent abuse. If you paid for your hosting, get in contact with your host so they can enable it for you.
If changing that setting is not an option, then have a look at the cURL library.
It seems "allow_url_fopen" setting is false on your server and hence does not allow using URLs with file_get_contents().
Try using CURL instead that is a better and efficient way of communicating with other server.