Reputation: 546
When I upload an image, there is no error it works fine. But when the image is displayed it shows the wrong image. It's currently showing an image that doesn't even exist. To be true when I was testing the upload function I used the same image all the time so I really didn't find any problem. Now when I upload another image (minion's image), it still displays the old image that I used for testing purpose. I dont know why. I even checked the folder manually and inside the folder, it shows the correct image but this is not the image that is shown in the view page.
Below is the code to store the image:
public function store(Request $request)
{
if(Auth::check())
{
if (Stock::where('tag_no','=',$request->input('tag_no'))->exists()) {
return back()->withInput()->with('errors', 'Tag number already used!');
}
$this->validate($request, [
'image' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:2048',
]);
$imageName = 'Tag '.$request->input('tag_no').'.'.$request->image->getClientOriginalExtension();
$request->image->move(public_path('/storage/'.Auth::user()->company.'/stock-images'), $imageName);
$stock = Stock::insert([
'tag_no' => $request->input('tag_no'),
'stock_type' => $request->input('stock_type'),
'image' => $imageName,
]);
if($stock){
return redirect()->route('stocks.index')
->with('success' , 'Stock created successfully');
}
}
return back()->withInput()->with('errors', 'Error creating new Stock');
}
So the path I'm storing is in " /public/storage/companyname/stock-images/ ".
And in the view page:
<a href="/storage/{{Auth::user()->company}}/stock-images/{{$stock->image}}" target="__blank">
<img class="pull-right" src="/storage/{{Auth::user()->company}}/stock-images/{{$stock->image}}" height="100" width="100"></a>
I tried clearing cache and config and also view still its the same. Someone, please suggest me something.
Upvotes: 0
Views: 168
Reputation: 8078
Run following Commands
php artisan clear or php artisan cache:clear
and
php artisan view:clear
if you running php artisan serve
then close terminal once and open terminal again
Still you are viewing old image then clear your browser cache and restart browser
Upvotes: 1