博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
fileinput 图片上传
阅读量:6864 次
发布时间:2019-06-26

本文共 1155 字,大约阅读时间需要 3 分钟。

//添加商品的时候上传图片,当编辑商品的时候,要把图片也显示出来,做法为下便的if判断,如果当前编辑的商品有images的路径,则赋值 绝对路径。
//代码中有个$data['images']  $data为当前商品的数据,$data['images']为当前商品存入数据库的图片路径
$("#kv-explorer").fileinput({
'theme': 'fa', language: 'zh', uploadUrl: "{
{ route('uploadImg','brand') }}", deleteUrl: "{
{ route('deleteImg') }}", allowedFileExtensions: ['jpg', 'jpeg', 'gif', 'png'], overwriteInitial: false, initialPreviewAsData: true, maxFileCount: 1, uploadExtraData: {"_token": "{
{ csrf_token() }}"}, deleteExtraData: {"_token": "{
{ csrf_token() }}"}, initialPreview: [ @if($data['images']) "http://" + "{
{ $data['images'] }}", @endif ], initialPreviewConfig: [ @if($data['images']) {
key: "{
{ $data['images'] }}" }, @endif ], }).on('fileuploaded', function (event, data, key) {
$('form').append(''); }).on('filepredelete', function () {
$(":input[name='images']").remove(); }).on('filesuccessremove', function () {
$(":input[name='images']").remove(); });

转载于:https://www.cnblogs.com/muwu/p/8939888.html

你可能感兴趣的文章