duandangqin0559 2014-12-18 21:48
浏览 62
已采纳

Laravel 4 - 刀片图像无法正常显示

I experienced an issue displaying my images via Laravel blade templating.

In my "change-profile.blade.php" file I have a form that allows authenticated users to change some profile info. In this specific case I want to display avatars based on gender input provided.

So far so good, my js works perfectly and my images url seems to be ok in terms of path. The problem is images result broken and I seriously don't know why. This is my code:

@extends('layout.main')
@section('content')
    <form action="{{ URL::route('profile-change-profile') }}" method="post">
        <fieldset class="change-profile">
            <legend>Change Profile</legend>
            <p>
                <input type="radio" class="gender" name="gender" value="male" /><span>male</span>
                <input type="radio" class="gender" name="gender" value="female" /><span>female</span> 
            </p>
            <p>
                <ul class="males gender">
                    @for ($i = 0; $i < 75; $i++)
                        <li><img src="{{ asset('assets/img/avatar/males/m-' . ($i+1) . '.png') }}" alt="avatar_male_{{ $i+1 }}"></li>
                    @endfor
                </ul>
                <ul class="females gender">
                    @for ($i = 0; $i < 40; $i++)
                        <li><img src="{{ asset('assets/img/avatar/females/f-' . ($i+1) . '.png') }}" alt="avatar_female_{{ $i+1 }}"></li>
                    @endfor
                </ul>
                <input type="hidden" class="avatar-src" name="avatar-src" value="" />
            </p>
            <p class="form-action">
                <button type="submit">submit</button>
                {{ Form::token() }}
            </p>
        </fieldset>
    </form>
@stop

My images are stored as png files in public/assets/img/avatar/(females|males)/(m|f)-n.png

Any help?

  • 写回答

2条回答 默认 最新

  • doucongmishang2385 2014-12-19 01:16
    关注

    Solution found! It wasn't something wrong in my code but just folder encryption. With folder encryption (due to zip folder or zip file saved on OSX) those files exist upon unzip process but they're not accessible (from a browser) until you disable the encryption itself manually. You can avoid this annoying problem experienced on Windows just right-clicking on "green" filename/folder, select advanced and get rid of the tick related to encryption (last one tick, left-bottom).

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 基于作物生长模型下,有限水资源的最大化粮食产量的资源优化模型建立
  • ¥20 关于变压器的具体案例分析
  • ¥15 生成的QRCode圖片加上下載按鈕
  • ¥15 板材切割优化算法,数学建模,python,lingo
  • ¥15 科来模拟ARP欺骗困惑求解
  • ¥100 iOS开发关于快捷指令截屏后如何将截屏(或从截屏中提取出的文本)回传给本应用并打开指定页面
  • ¥15 unity连接Sqlserver
  • ¥15 图中这种约束条件lingo该怎么表示出来
  • ¥15 VSCode里的Prettier如何实现等式赋值后的对齐效果?
  • ¥20 keepalive配置业务服务双机单活的方法。业务服务一定是要双机单活的方式