I have used following way to store file in public folder through api but file data damazed or corrupted
1st way:-
$filename="Pqr.pdf";
$resume="http://localhost/project_name/public/datafiles/APPL/Xyz.pdf"; //url link of 1st laravel project
file_put_contents(public_path('datafiles/APPL').'/'.$filename, fopen($resume, 'r')); //file upload in 2nd laravel project
2nd way:-
$filename="Pqr.pdf";
$resume="http://localhost/project_name/public/datafiles/APPL/Xyz.pdf";
file_put_contents(public_path('datafiles/APPL').'/'.$filename,file_get_contents($resume);
3rd way:-
$filename="Pqr.pdf";
$resume="http://localhost/project_name/public/datafiles/APPL/Xyz.pdf";
$data=file_get_contents($resume);
file_put_contents(public_path('datafiles/APPL').'/'.$filename,base64_decode($data));
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire