aayush's avatar

Get path of file stored in storage/apps/files/data/filename.csv

I have successfully uploaded file to storage/apps using storage::disk('local'). Now, I want to retrieve this file. So far, I have tried with :

$csv_file_path = storage_path('files/data/').$request->filename;

It returns path like C:\wamp64\www\project\storage/files/data/5af9b0c1cfa8f.csv

But with error, C:\wamp64\www\project\storage/files/data/5af9b0c1cfa8f.csv: failed to open stream: No such file or directory

Even though there is such file. What am I doing wrong here. Does it looking for path like localhost/project/storage.......

On next step, I am trying to do $csv = Reader::createFromPath($csv_file_path, 'r');

This file will be parsed using CSV league on few steps below. And all the process below were working previously when I was trying with

$csv_file_path = public_path('assets/files/data/').$request->filename

Previously, i was uploading it to public folder with move methods.

0 likes
4 replies
Cronix's avatar

$csv_file_path = storage_path('files/data/').$request->filename; It returns path like C:\wamp64\www\project\storage/files/data/5af9b0c1cfa8f.csv

But with error, C:\wamp64\www\project\storage/files/contribution/5af9b0c1cfa8f.csv: failed to open stream: No such file or directory

That doesn't make sense. Those are 2 different paths. How do you get the 2nd path that you showed when using the $csv_file_path variable, which shows a different directory? One path contains data while the other contains contribution?

jlrdw's avatar

After $csv_file_path = storage_path('files/data/').$request->filename; What are you trying to do?

You are getting an error just for assigning $csv_file_path.

Inquisitive's avatar
Level 9

Update

$csv_file_path = storage_path('files/data/').$request->filename;

to

$csv_file_path = storage_path('app/files/data/').$request->filename;

You are missing app

1 like

Please or to participate in this conversation.