Laravel 8 - How to copy file from one folder to another folder

Laravel 8 - How to copy file from one folder to another folder

In this Laravel Tutorial, I will let you know how to copy one file from one folder to another with example.

Copying file from one location to another location is very common and general activity that you regularly do on your system with the help of GUI.

And If you are familiar with Linux then there is a command cp to copy file from one location to another. In Laravel, we can achieve it by using copy method with File or Storage Facade.

Copy file using File Facade

You can simply use below syntax to copy file from one path to another, you just need to replace the from_path and to_path to their actual path

File::copy(from_path, to_path);
Copy file using Storage Facade

Storage Facade is another way to copy file from one location to another:

Storage::copy(from_path, to_path);

Let's suppose you want to copy the file 'file1.jpg' from old directory to new directory then you can use below line of code

Storage::copy('old/file.jpg', 'new/file.jpg');

Phone: (+91) 8800417876
Noida, 201301
sakarya escort sakarya escort bayan sakarya escort serdivan escort sakarya escort sakarya escort serdivan escort
karasu escort akyazı escort serdivan escort akyazı escort ferizli escort sapanca escort serdivan escort söğütlü escort sakarya escort izmit escort arifiye escort erenler escort hendek escort kocaali escort pamukova escort taraklı escort geyve escort