gpt4 book ai didi

dropzone.js - 如何显示jQuery Dropzone的错误消息

转载 作者:行者123 更新时间:2023-12-03 13:44:41 29 4
gpt4 key购买 nike

我将dropzone与CI结合使用,我不知道在上传false时如何显示错误消息和自定义消息,这是我的脚本

Dropzone.autoDiscover = false;
try {
var myDropzone = new Dropzone("#adminform" , {
paramName: "filename", // The name that will be used to transfer the file
maxFilesize: 0.5, // MB
url: window.location.href,
addRemoveLinks : true,
dictDefaultMessage :
'<span class="bigger-150 bolder"><i class="ace-icon fa fa-caret-right red"></i> Drop files</span> to upload \
<span class="smaller-80 grey">(or click)</span> <br /> \
<i class="upload-icon ace-icon fa fa-cloud-upload blue fa-3x"></i>',
dictResponseError: 'Error while uploading file!',

//change the previewTemplate to use Bootstrap progress bars
previewTemplate: "<div class=\"dz-preview dz-file-preview\">\n <div class=\"dz-details\">\n <div class=\"dz-filename\"><span data-dz-name></span></div>\n <div class=\"dz-size\" data-dz-size></div>\n <img data-dz-thumbnail />\n </div>\n <div class=\"progress progress-small progress-striped active\"><div class=\"progress-bar progress-bar-success\" data-dz-uploadprogress></div></div>\n <div class=\"dz-success-mark\"><span></span></div>\n <div class=\"dz-error-mark\"><span></span></div>\n <div class=\"dz-error-message\"><span data-dz-errormessage></span></div>\n</div>",
});
}
catch(e) {
alert('Dropzone does not support older browsers!');
}

PHP返回400:
$this->output->set_header("HTTP/1.0 400 Bad Request");

但是,当我将图像悬停在[object Object]上时,消息是:

dictResponseError: 'Error while uploading file!'

最佳答案

对于任何有需要的人:

您可以使用echo从服务器返回响应消息。然后在js代码中添加错误事件处理程序

的PHP

header("HTTP/1.0 400 Bad Request");
echo "Ups error message";

JS
this.on('error', function(file, response) {
$(file.previewElement).find('.dz-error-message').text(response);
});

关于dropzone.js - 如何显示jQuery Dropzone的错误消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27030652/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com