Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/unix/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在Krajee Boostrap文件输入中删除图像?_Javascript_Php_Jquery_Html_Upload - Fatal编程技术网

Javascript 如何在Krajee Boostrap文件输入中删除图像?

Javascript 如何在Krajee Boostrap文件输入中删除图像?,javascript,php,jquery,html,upload,Javascript,Php,Jquery,Html,Upload,目前正在我的网站上上传图片时,我正在努力寻找一种方法,当用户在上传图片后点击删除按钮时,触发一个事件来调用我的php文件。(删除功能是如何工作的?) (我的上传工作正常!只是无法启动删除部分) html: JS代码: $("#input-upload").fileinput({ uploadUrl: 'uploadImg.php', deleteUrl: 'deleteImg.php', showCaption: false,

目前正在我的网站上上传图片时,我正在努力寻找一种方法,当用户在上传图片后点击删除按钮时,触发一个事件来调用我的php文件。(删除功能是如何工作的?)

(我的上传工作正常!只是无法启动删除部分)

html:


JS代码:

$("#input-upload").fileinput({
        uploadUrl: 'uploadImg.php',
        deleteUrl: 'deleteImg.php',
        showCaption: false,
        dropZoneEnabled: false,
        maxFileSize: 7000,
        maxFileCount: 5,
        uploadAsync: false,
        allowedFileExtensions : ['jpg', 'png','gif'],


        previewFileType: "image",
    browseClass: "btn btn-success",
    browseLabel: "Pick Image",
    browseIcon: '<i class="glyphicon glyphicon-picture"></i>',
    removeClass: "btn btn-danger",
    removeLabel: "Delete",
    removeIcon: '<i class="glyphicon glyphicon-trash"></i>',
    uploadClass: "btn btn-info",
    uploadLabel: "Upload",
    uploadIcon: '<i class="glyphicon glyphicon-upload"></i>',
        initialPreviewShowDelete:true,

    });
$(“#输入上载”).fileinput({
uploadUrl:'uploadImg.php',
deleteUrl:'deleteImg.php',
说明:错,
dropZoneEnabled:错误,
最大文件大小:7000,
maxFileCount:5,
uploadAsync:false,
允许的文件扩展名:['jpg','png','gif'],
预览文件类型:“图像”,
browseClass:“btn btn成功”,
browseLabel:“拾取图像”,
browseIcon:“,
removeClass:“btn btn危险”,
删除标签:“删除”,
removeIcon:“,
uploadClass:“btn btn信息”,
上传标签:“上传”,
上载图标:“”,
initialPreviewShowDelete:true,
});
我还尝试了各种事件,比如filepredelete和filedeleted函数,但当用户点击delete按钮时,这些事件从未被调用。只有fileclear事件起作用,但这是毫无意义的,因为我将始终返回一个空列表,并且它没有用处,因为我无法删除服务器上上载的文件

我想找到一种方法来获取当前列表,或者找出用户删除的图像,以便我可以在服务器中删除它。(在删除之前和之后获取我的输入上载数组)


有人能帮我吗?提前谢谢

为上载的图像添加初始预览
初始预览

initialPreview: {
    `img src='/images/desert.jpg' class='file-preview-image' alt='Desert' title='Desert'>`",
    `<img src='/images/jellyfish.jpg' class='file-preview-image' alt='Jelly Fish' title='Jelly Fish'>`",
},

为上载的图像添加初始预览
初始预览

initialPreview: {
    `img src='/images/desert.jpg' class='file-preview-image' alt='Desert' title='Desert'>`",
    `<img src='/images/jellyfish.jpg' class='file-preview-image' alt='Jelly Fish' title='Jelly Fish'>`",
},

为上载的图像添加初始预览
初始预览

initialPreview: {
    `img src='/images/desert.jpg' class='file-preview-image' alt='Desert' title='Desert'>`",
    `<img src='/images/jellyfish.jpg' class='file-preview-image' alt='Jelly Fish' title='Jelly Fish'>`",
},

为上载的图像添加初始预览
初始预览

initialPreview: {
    `img src='/images/desert.jpg' class='file-preview-image' alt='Desert' title='Desert'>`",
    `<img src='/images/jellyfish.jpg' class='file-preview-image' alt='Jelly Fish' title='Jelly Fish'>`",
},

有参考的样本代码吗?我想我以前也试过。它似乎不起作用您的postImages代码(函数)必须返回包含以下数据的json格式:echo json_encode(['initialPreview'=>[“”,],'initialPreviewConfig'=>[['caption'=>“example.jpg”,'width'=>'120px','url'=>delete/image/id','key'=>{key}],],'append'=>true])@RyanFung,reference:我不明白我需要在url键中传递什么值?我的意思是,我需要发送删除图像的.php url?有参考的示例代码吗?我想我以前也试过。它似乎不起作用您的postImages代码(函数)必须返回包含以下数据的json格式:echo json_encode(['initialPreview'=>[“”,],'initialPreviewConfig'=>[['caption'=>“example.jpg”,'width'=>'120px','url'=>delete/image/id','key'=>{key}],],'append'=>true])@RyanFung,reference:我不明白我需要在url键中传递什么值?我的意思是,我需要发送删除图像的.php url?有参考的示例代码吗?我想我以前也试过。它似乎不起作用您的postImages代码(函数)必须返回包含以下数据的json格式:echo json_encode(['initialPreview'=>[“”,],'initialPreviewConfig'=>[['caption'=>“example.jpg”,'width'=>'120px','url'=>delete/image/id','key'=>{key}],],'append'=>true])@RyanFung,reference:我不明白我需要在url键中传递什么值?我的意思是,我需要发送删除图像的.php url?有参考的示例代码吗?我想我以前也试过。它似乎不起作用您的postImages代码(函数)必须返回包含以下数据的json格式:echo json_encode(['initialPreview'=>[“”,],'initialPreviewConfig'=>[['caption'=>“example.jpg”,'width'=>'120px','url'=>delete/image/id','key'=>{key}],],'append'=>true])@RyanFung,reference:我不明白我需要在url键中传递什么值?我的意思是,我需要发送删除图像的.php url?