I am trying to read file content of (.stl) file, from an external link, my code is as bellow
if($request->filled('link')) {
$file = file_get_contents($request->link);
$file_name = now()->format('YmdHi'). rand(12321, 45654664) . '.stl';
file_put_contents(public_path('model-files/' . $file_name), $file);
}
However everthing works fine, and i am not getting any code error, but when i tries to open the file, the file do not open, saying "File can not be opened". If i open the file link directly in the browser, it downloads and open just fine, also the file size of the file stored by code is also not the same to original link file, so i am not sure if all content of file is read properly or not, please guide