Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

PeterF's avatar

Where to save images and how to retrieve them?

I seem to be failing on something genuinely simple. Perhaps that means its time to stop coding on a saturday night, and just go to sleep.....

So I use livewire file upload to load an image.

I construct a path and save it like this....

$date = Carbon::parse($this->day);
$path = 'public/'.Auth::id().'/charts/'.$date->year.'/'.$date->month.'/'.$date->day.'/'.$this->currentSession->trading_session_id;
$this->currentSession->imageURL = $this->imageURL->store($path);

And then this->currentSession->imageURL is saved into my database. Then later, I want to put that picture on the page in my blade file like this

<img src="{{ asset($oldImageURL) }}" width=600 height=500 />

where oldImageURL is the previously stored result from the livewire store command. But it doesn't work. It gets a 404...... SO I have tried it without asset(), I have tried it with 'public' at the front, I have tried it with storage at the front.... I have run the Filesystem links... I have done everything I can think of, but just cant find that file again to display... its there in the file system... it saved... I just can't workout how I am meant to get it back as a value to plug into an IMG tag.....

0 likes
2 replies
kokoshneta's avatar

Where is it stored in the filesystem? And what is $oldImageURL?

PeterF's avatar
PeterF
OP
Best Answer
Level 6

Turns out the livewire store, by default, goes into the 'local' disk, which in filesystem config, is at the storage path of 'app' whereas the asset() call, likes to look in app/public, which is in fact the public filesystem, not the local filesystem. So the answer was, to change the store command to

$this->currentSession->imageURL = $this->imageURL->store($path, 'public');

Please or to participate in this conversation.