Skip to content

Laravel Copy File from One Folder to Another

Last updated on March 30, 2022

In this tutorial, you will learn how to copy files from one folder to another folder in your Laravel application.

You can use File or Storage Facade to access file system methods. You should use the copy() method to copy files from one location to another.

The File Facade just contains some primitive methods that work only with absolute path or relative to your script.

The Storage Facade contains a set of complex methods and is a wrapper for other 3rd party tools. You can use the relative path to a storage folder.

You Can change the default storage folder storage/app in config/filesystems.php

Copy with File Facade 

File::copy(public_path('oldLocation/oldFileName.png'), public_path('newLocation/NewFileName.png'));

Copy with Storage Facade

Storage::copy('oldLocation/oldFileName.png', 'newLocation/NewFileName.png');

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments