To access files in the storage folder, you can use the storage_path() function provided by Laravel. This function returns the absolute path to the storage directory. You can then append the relative path to your file to this path to get the full path to the file.
Here's an example:
// Assuming $file contains the name of the uploaded file
$filePath = storage_path('app/code/' . $file);
// Check if the file exists
if (file_exists($filePath)) {
// Do something with the file
} else {
// File not found
}
In this example, we're using the storage_path() function to get the absolute path to the storage directory. We're then appending the relative path to our file (app/code/ followed by the file name) to this path to get the full path to the file.
We're then checking if the file exists using the file_exists() function. If the file exists, we can do something with it. If not, we can handle the error appropriately.
Note that we're using the app directory within the storage directory. This is because files uploaded by your application should be stored in the storage/app directory. If you want to store files in a different directory within the storage directory, you can replace app with the name of your directory.