Level 73
My guess is that you are in the wrong directory . Have you run the php artisan storage:link command?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hey, basic php function file_get_content every time times out into a "Failed to open stream: HTTP request failed!".
My setup:
I've tried:
allow_url_fopen to true$opts = array('http'=>array('header' => "User-Agent:MyAgent/1.0\r\n"));
$context = stream_context_create($opts);
$file = file_get_contents(asset('images/cross.png'), false, $context);
Any idea why it's not working? I originally wanted to perform imagecreatefrompng() function and I figured out that basic file_get_contents doesn't work.
I figured it out. You have to use public_path('your/path') not asset('your/path') for file_get_contents() and imagecreatefrompng().
Please or to participate in this conversation.