0

Laravel Excel 3.1 Laravel 8.75 PHP 7.4

Hello! I am using Laravel Excel package (https://github.com/SpartnerNL/Laravel-Excel) to export xlsx and csv files with text and images inside. I do from a view:

<table>
    <thead>
    <tr>
        <th>Image</th>
        <th>Name</th>
        <th>SKU</th>
    </tr>
    </thead>
    <tbody>
          @foreach ($order->order_items as $item)
              <tr>              
                 <td><img src="{{ public_path('storage/' . $item->product->image) }}"</td> 
                  <td>{{ $item->product->name }}</td> 
                  <td>{{ $item->product->sku }}</td> 
              </tr>
          @endforeach
    </tbody>
</table>

In my local environment there is no problem but in production I get the following message:

File http://expo.zlestore.com/storage/products/rvhmSggWJquRpQvYLUMUvXEeUJzhlBx0xhDd4qal.jpg does not exist

I already run the storage link command and it is working. If I go to that link I see there is an image, the file actually exists but I can't export the file.. I tried different ways but without successs:

1) src="{{ Storage::url($item->product->image) }}">
2) src="{{ public_path('storage/' . $item->product->image) }}">
3) src='https://expo.zlestore.com/storage/' . $item->product->image>
4) src="{{asset('storage/'.$item->product->image)}}"

Could you help me with this?

Thank you in advance!

If I delete the img tag line everything works fine. I expect the xlsx file to be exported correctly with images inside.

1 Answer 1

0

Solved. The correct way is

<img src="{{storage_path('app/public/'.$item->product->image)}}">
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.