首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >`console.log(responseText);`和`console.log(文件);`不显示任何数据

`console.log(responseText);`和`console.log(文件);`不显示任何数据
EN

Stack Overflow用户
提问于 2014-11-19 10:03:50
回答 1查看 1.6K关注 0票数 2

我正在使用下面的下拉区域配置。我的问题是,文件正在服务器中上载,但是console.log(response);console.log(file);没有在控制台中显示任何内容。另外,移除链接没有添加到图片中。

代码语言:javascript
复制
<form action="UploadImages"
      class="dropzone"
      id="image-uploader" enctype="multipart/form-data">
    <i class="fa fa-image" id="dzopen"></i>
</form>                
<div id="media-upload-previews">
</div>
 Dropzone.options.dz = {
        paramName: "file",
        maxFilesize: 10,
        url: 'UploadImages',
        previewsContainer: "#media-upload-previews",
        uploadMultiple: true,
        parallelUploads: 5,
        maxFiles: 20,
        acceptedFiles: "image/*,audio/*,video/*",
        init: function() {
            this.on("success", function(file, responseText) {
                var response = jQuery.parseJSON(responseText);
                alert(file);
                alert(responseText);
              });
            this.on("thumbnail", function(file, dataUrl) {
                $('.select_img').html('<img src="' + dataUrl + '" width="50" height="50" alt="">');
            });
            this.on("removedfile", function(file) {
            });
        }
    }

编辑:这里我想显示50的图像(默认预览的insted),上传后我想在控制台中显示file, responseText值,这样我就可以将其用于删除。但这并没有显示特定宽度和高度的硬币,上传后也没有给出控制台的响应。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-12-08 05:15:28

试过这种正常工作的http://jsfiddle.net/xrcwrn/y8697re4/4/

代码语言:javascript
复制
$("i#dzopen").dropzone({
    paramName: "file",
    maxFilesize: 10,
    url: 'UploadImages',
    previewsContainer: "#media-upload-previews",
    uploadMultiple: true,
    parallelUploads: 5,
    maxFiles: 20,
    acceptedFiles: "image/*,audio/*,video/*",
    init: function () {
        this.on("success", function (file, responseText) {
            alert(file);
            alert(responseText);
           console.log(file);
        });
        this.on("thumbnail", function (file, dataUrl) {
            $('#media-upload-previews').append('<img src="' + dataUrl + '" width="50" height="50" alt="">');
        });
        this.on("removedfile", function (file) {});
        this.on("complete", function (file) {
            alert(file);
        });
    }
});
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27013955

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档