Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

socieboy's avatar

Download a file with laravel

I'm working with a external API, this API give me a list of students assigned to the given class ID, and I need to download the certificates of those students to my local server. The API give me a temporary URL of the certificate, how can I pull the certificate to my server with laravel?

0 likes
3 replies
voxatik's avatar
voxatik
Best Answer
Level 40

You could use php's fopen function passing in the url and save the returned data.

Storage::put('file.zip', fopen("http://someurl/file.zip", 'r'));

2 likes
accent-interactive's avatar

You may want to be extra careful when pulling in external files, as that can pose a pretty grave security hazard. E.g. only enable admins to do so, whitelist server ip adress, use an ssl connection, etc.

Please or to participate in this conversation.