imagecreatefrompng() and remote files...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
UltimateWalrus
Forum Newbie
Posts: 2
Joined: Sat Feb 21, 2009 10:44 pm

imagecreatefrompng() and remote files...

Post 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.
Last edited by UltimateWalrus on Sat Feb 21, 2009 11:10 pm, edited 1 time in total.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: imagecreatefrompng() and remote files...

Post 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.
UltimateWalrus
Forum Newbie
Posts: 2
Joined: Sat Feb 21, 2009 10:44 pm

Re: imagecreatefrompng() and remote files...

Post 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:
Post Reply