简体   繁体   中英

getimagesize() read error laravel -blade-view

I have a blade view file with this piece of code in it.

@if(count($news))
                        @foreach($news as $nieuwtje)

                        <?php list($width, $height) = getimagesize(public_path() . '/uploads/nieuwtjes/small/' . $nieuwtje->image);  ?>
                            <li>

                                {{ HTML::image(public_path() . '/uploads/nieuwtjes/small/' . $nieuwtje->image,'', array('class' => 'scale-with-grid', 'height' => $height, 'width' => $width)); }}
                                <div class="slide-cnt">
                                    <h2>{{{$nieuwtje->title}}}</h2>
                                    <p>{{{$nieuwtje->first_paragraph}}} </p>
                                    <a href="#" class="red-btn">Lees hier meer!</a>
                                </div>
                            </li>
                        @endforeach
                        @endif

It prints down the correct value when I echo the $width or $height. Can someone help me with this?

Thanks !

This error occurs because image doesn't exist in provided path

echo this path: public_path() . '/uploads/nieuwtjes/small/' . $nieuwtje->image;

and see if image exists.

Do you have proper access to the public folder? Even if you have access to that folder, you may run into problems when you add new images into that folder. The newly added image may not be accessible.

Check out the access on the image by 'ls -a' on max os and linux.

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM