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 sakarya escort sakarya escort serdivan escort izmir escort eporner
akyazı escort sakarya escort ferizli escort sakarya escort geyve escort sakarya escort hendek escort sakarya escort karasu escort sakarya escort sapanca escort serdivan escort webmaster forum
pendik escort atasehir escort