-1

i am using image intervention to upload images in Laravel 8 and it works well in the local host but in the host, I get this error message

file_get_contents(): data:// wrapper is disabled in the server configuration by allow_url_fopen=0

and I have no ability to change anything in php.int, so is there any way to use something instead of using file_get_contents()

here is my code in controller to upload image.

Image::make(file_get_contents($back))->save($path_b);     

knowing that after searching I could not know how to use the method below

function fOpenRequest($url) {
   $file = fopen($url, 'r');
   $data = stream_get_contents($file);
   fclose($file);
   return $data;
}
$fopen = fOpenRequest('https://www.example.com');
user3783243
  • 5,098
  • 5
  • 16
  • 37
  • 1
    A network URL requires `allow_url_fopen`. There's no way to get around that. `fopen` and `file_get_contents` both require it. – user3783243 Dec 31 '21 at 16:36
  • 1
    If you can't change php.ini, then check if cURL is enabled and use that instead. If that isn't installed/enabled either, then you're starting to run out of options. – M. Eriksson Dec 31 '21 at 16:39
  • Use Laravel's built-in HTTP client. https://laravel.com/docs/8.x/http-client – miken32 Dec 31 '21 at 16:41

1 Answers1

1

I recommend you to use spatie media library

Abdul Rehman
  • 179
  • 5