I am running PHP's built in server with php -S localhost:7777
. I am trying to do some stuff with images and I need to access the files through an absolute path like:
$image = imagecreatefromjpeg('http://localhost:7777/img/rainbow.jpg');
But the server just times out when I try this, even though allow_url_fopen = On
in php.ini and I also tried making sure it was on with ini_set('allow_url_fopen', true)
. I also tried the solution in this SO question, using curl and it still times out just the same. However it does work to use a relative path, like:
$image = imagecreatefromjpeg('../img/rainbow.jpg');
Why should this be? I need it to be an absolute path because I need to route requests for images through an image resizer script, SLIR, which requires URLs in the form /SLIR/w500-h300/path/to/image.jpg
, but the routing doesn't work through things like imagecreatefromjpeg()
I believe because that isn't an HTTP request, but maybe I am mistaken about that?