John Davidson

php - Where Laravel Storage save the files?

0 comments
Message:


hope you are doing really good today, I'm trying to copy a file using the function copy from Laravel Storage, but I don't know where it is saving them cause the first time looks normal but after the second shot I got an error about the file already exists, but I don't know where is saving it, this is my code, $dirDest should be a folder inside of my project but is not saving it there and I've already searched it in the ftp directory, hope you can help me.


$dirDest = 'temp-docs\temp.pdf';
Storage::disk('custom-ftp')->copy($this->document_path, $dirDest);

Regards!


My Answer:
> The Laravel Storage saves files in the `storage/app` directory by default. However, when using a custom disk like `custom-ftp`, the files are saved in the location specified in the configuration for that disk.

In your case, if you are trying to save the file to a folder inside your project, you should specify the full path to that folder in the `$dirDest` variable. For example, if you want to save the file in a folder named `temp-docs` inside the `storage/app` directory, you can do the following:

php
$dirDest = 'temp-docs/temp.pdf';


This will save the file in the `storage/app/temp-docs` directory. Make sure that the folder `temp-docs` exists before trying to save the file there.

If you are still unable to find the file after saving it, you can use the `Storage::url()` method to get the public URL of the saved file and check where it is located.

Rate this post

3 of 5 based on 3515 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us