I\'ve been looking all over the place for the last two days and trying everything and still can\'t get anything to work. I feel like this should be a relatively simple thin
With validations...
Validate if file exists first:
function doesUrlExists($url) {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_exec($ch);
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if($code == 200){
$status = true;
}else{
$status = false;
}
curl_close($ch);
return $status;
}
And then put file content (with laravel storage class):
if(!doesUrlExists($url_file)) {
die('The remote file is not accessible. Please check the URL.');
}
Storage::disk('local')
->put($file_destintation, fopen($url_file, 'r'));