如何在laravel 5.4中的公用文件夹中调用图像

时间:2017-08-09 02:35:42

标签: laravel laravel-5 laravel-5.4

我的问题很简单

我正在尝试在img文件夹中的公共文件夹中调用此源:

src="img/vcc3logo.png"

但我无法在我的pdf打印表格中显示它

当客户打印认证表格时,需要显示图像。 print.blade.php的文件位于resources / views / customer-relations / dashboard / print.blade.php

这是我的print.blade.php中的代码

    {{--   <div class="content">
        <div class="clearfix"></div>
            <div class="box-body"> --}}

            <img src="" height="50" width="50" style="float: right">
            <img src="img/vcc3logo.png" height="50" width="50" style="float: left">

            <div class="container">
            <div class="row">
                <div class="text-center">
                <p class="text-center maliit">
                Republic of the Philippines<br>
                 National Capital Region<br>
                <font>City Government of Valenzuela</font><br>
                   Office of the City Mayor<br>
            Valenzuela City Command and Communications Center<br>
    2nd Floor, City ALERT Center, Mc-Arthur Hi-way, Malinta, Valenzuela City<br>
    </p>
                    <h3>Application Number:{{ $application_number }}</h3>
                </div>
                <h5><b>Business Name:</b> {{ $business_name }}</h5>
                <h5><b>Owner:</b> {{ $owner }}</h5>
                <h5><b>Location:</b> {{ $location }}</h5>
                </span>
                <table class="table table-hover">
                    <thead>
                        <tr>
                            <th>Fees</th>
                            <th></th>
                            <th class="text-center"></th>
                            <th class="text-center"></th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td class="col-md-9"><em>Inspection Fee:</em></h4></td>
                            <td class="col-md-1" style="text-align: center"></td>
                            <td class="col-md-1 text-center"></td>
                            <td class="col-md-1 text-center">{{ $inspection_fee }}</td>
                        </tr>

                        <tr>
                            <td class="col-md-9"><em>Certificate Fee:</em></h4></td>
                            <td class="col-md-1" style="text-align: center"></td>
                            <td class="col-md-1 text-center"></td>
                            <td class="col-md-1 text-center">{{ $cert_fee }}</td>
                        </tr>
                        <tr>
                            <td class="col-md-9"><em>Local Fee:</em></h4></td>
                            <td class="col-md-1" style="text-align: center"></td>
                            <td class="col-md-1 text-center"></td>
                            <td class="col-md-1 text-center">{{ $local_fee }}</td>
                        </tr>
                        <tr>
                            <td class="col-md-9"><em>Others Fee:</em></h4></td>
                            <td class="col-md-1" style="text-align: center"></td>
                            <td class="col-md-1 text-center"></td>
                            <td class="col-md-1 text-center">{{ $others_fee }}</td>
                        </tr>
                    </tbody>
                </table>
                <p><i>Note: Please print and present to Customer Relations Officer</i></p>
                </td>
            </div>
        {{-- </div>
        </div>
    </div>
 --}}

我尝试将其更改为

src="url('/img/cctv_camera.jpg')"

但最终出现了这个错误:

(1/1)RuntimeException 退出状态代码&#39; 1&#39;说出了问题: stderr:&#34;加载页面(1/6)

2 个答案:

答案 0 :(得分:1)

如果图片文件位于公共文件夹内,则需要添加asset(),其中包含完整的图片路径,如

<img src="{{asset('/img/vcc3logo.png')}}" height="50" width="50" style="float: left">

答案 1 :(得分:0)

我想你可以尝试这个希望对你的帮助:

<img src="{{asset('/img/vcc3logo.png')}}" height="50" width="50" style="float: left">

 System.out.println("Enter the name: ");
String name = scanner.nextLine();
if(!StringUtils.isAlphaSpace(name)){
   throw new MyException("Name is not valid");
}else{
  e.setName(name);
}

public class MyException extends Exception{
 public MyException (String message){
super(message);
}

}

希望这对你有用!!!