Home > Backend Development > PHP Tutorial > Creating Temporary URLs for Local Files in Laravel

Creating Temporary URLs for Local Files in Laravel

Mary-Kate Olsen
Release: 2024-09-28 12:40:02
Original
1139 people have browsed it

Creating Temporary URLs for Local Files in Laravel

Working with private files in Laravel usually means involving third-party services like S3 or DigitalOcean. But what if you’re in a local development environment or have a lightweight project? You might not want to depend on third-party cloud services.

Luckily, Laravel makes it easy to serve temporary URLs for files stored locally. This approach can speed up development and simplify file sharing.

You just need to change the FILESYSTEM_DISK to local from your .env file.

FILESYSTEM_DISK=local
Copy after login

Next, check your config/filesystems.php file. Under the 'local' disk configuration, set 'serve' => true, if it's not there you can add it.

Once your configuration is set, you can use Laravel's Storage::temporaryUrl() to create URLs that expire after a defined time, keeping your files secure.

Here's a more detailed version of this article to help you understand better if you could catch on: https://laraveleco.com/laravel-how-to-create-temporary-url-for-files-in-local-disk/


If you liked this article and want to support, you can do so by buying me a coffee.

The above is the detailed content of Creating Temporary URLs for Local Files in Laravel. For more information, please follow other related articles on the PHP Chinese website!

source:dev.to
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template