Page 1 of 1

imagecreatefrompng() and remote files...

Posted: Sat Feb 21, 2009 10:51 pm
by UltimateWalrus
Hi,

I'm trying to do something that should be pretty simple... I already have gotten a statement like this to work:

$img = imagecreatefrompng("image.png");

However, I'm having trouble getting a statement like this to work:

$img = imagecreatefrompng("http://somewebsite.com/image.png");

It gives me the message, "Warning: imagecreatefrompng() [function.imagecreatefrompng]: URL file-access is disabled in the server configuration".

According to the PHP documentation, "Windows versions of PHP prior to PHP 4.3.0 do not support access of remote files via this function, even if allow_url_fopen is enabled." But I know I am using PHP5 (I tried "phpversion()"). My only guess is that my webhost (1and1) has disabled this option in their php.ini file. But following their instructions on how to change it did not help.

Anyone have any ideas or suggestions that I could try?

I have also tried using "copy()" to copy remote files, but I get the same error.

Re: imagecreatefrompng() and remote files...

Posted: Sat Feb 21, 2009 11:09 pm
by requinix
What were the instructions?

I think you can override it with a simple

Code: Select all

ini_set("allow_url_fopen", 1);
or with

Code: Select all

php_flag allow_url_fopen on
in a .htaccess file.

Re: imagecreatefrompng() and remote files...

Posted: Sat Feb 21, 2009 11:22 pm
by UltimateWalrus
http://faq.1and1.com/scripting_language ... hp/14.html

Those were the instructions on how to change php.ini directives...

I tried the stuff you said. The first one did nothing, and the second one returned an "error 500: internal server error" page. Maybe it's because 1and1 has somehow "locked" this value and won't let me change it.

Oh, well. I guess I'll have to figure a way around it.

Thanks for your help anyway.

EDIT: YES!! I got it working by putting a file called php.ini in the exact same directory as my PHP file. All that's inside of it is the text, "allow_url_fopen=1". I guess that was just the magic thing that I had to do. Yay! :mrgreen: