【问题标题】:How to show the input type file value after form is submited and there are errors?表单提交后出现错误如何显示输入类型文件值?
【发布时间】:2018-07-27 17:37:50
【问题描述】:

当用户提交表单时,如果有任何错误,应使用提交的值填充字段,这样用户就不需要再次插入这些值。这工作正常,但图像字段不起作用。

我有以下代码:

<form method="post" class="clearfix" action="{{route('post.store')}}" enctype="multipart/form-data">
    <div class="form-row">
        <div class="form-group col">
            <label for="image">Image</label>
            <label class="custom-file">
                <input type="file" id="file" name="image" value="{{ old('image') }}" class="custom-file-input">
                <span class="custom-file-control"></span>
            </label>
        </div>
    </div>
</div>

你知道为什么表单提交后出现错误图片的路径没有出现吗?

【问题讨论】:

  • 什么意思?您是否试图代表用户从本地文件系统中“预选”一个文件?你不能这样做

标签: jquery html twitter-bootstrap laravel


【解决方案1】:

不,文件输入不能由 Laravel 或任何软件预填充。您的网站(和任何网站)不知道也不应该知道文件的本地路径。想象一下,如果他们这样做了会带来安全风险!你可以欺骗用户上传他们的 SSH 私钥或其他东西。

参考https://stackoverflow.com/a/33158509/7809177

【讨论】:

    猜你喜欢
    • 2012-12-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-01
    • 1970-01-01
    • 1970-01-01
    • 2022-07-22
    • 2015-11-16
    • 2019-06-06
    相关资源
    最近更新 更多