Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/445.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 如何检查dropzone.js引导示例中是否添加了文件?_Javascript_Jquery_Dropzone.js - Fatal编程技术网

Javascript 如何检查dropzone.js引导示例中是否添加了文件?

Javascript 如何检查dropzone.js引导示例中是否添加了文件?,javascript,jquery,dropzone.js,Javascript,Jquery,Dropzone.js,输入文件类型已设置为按钮样式。我不明白的是如何抓取文件输入来检查它是否已被添加 Dropzone配置 var myDropzone = new Dropzone(".container", { // Make the whole body a dropzone url: "/images-save", // Set the url thumbnailWidth: 80, thumbnailHeight: 80, parallelUploads: 20, previewTemp

输入文件类型已设置为按钮样式。我不明白的是如何抓取文件输入来检查它是否已被添加

Dropzone配置

var myDropzone = new Dropzone(".container", { // Make the whole body a dropzone
  url: "/images-save", // Set the url
  thumbnailWidth: 80,
  thumbnailHeight: 80,
  parallelUploads: 20,
  previewTemplate: previewTemplate,
  maxFilesize: 255,
  maxFiles: 1,
  autoQueue: false, // Make sure the files aren't queued until manually added
  previewsContainer: "#previews", // Define the container to display the previews
  clickable: ".fileinput-button", // Define the element that should be used as click trigger to select files.
  acceptedFiles: ".png,.jpg,.gif,.jpeg",
  dictFileTooBig:"image file exceeds ----", 
  autoProcessQueue: false,
});
  <div id="actions" class="row">
      <div class="col-lg-7">

        <!-- The fileinput-button span is used to style the file input field as button -->
        <span class="btn btn-success fileinput-button dz-clickable">
            <i class="glyphicon glyphicon-plus"></i>
            <span>Add files...</span>
        </span>
        <button type="submit" class="btn btn-primary start" >
            <i class="glyphicon glyphicon-upload"></i>
            <span>Start upload</span>
        </button>
        <button type="reset" class="btn btn-warning cancel">
            <i class="glyphicon glyphicon-ban-circle"></i>
            <span>Cancel upload</span>
        </button>
      </div>
  </div>
Dropzone.js引导程序

var myDropzone = new Dropzone(".container", { // Make the whole body a dropzone
  url: "/images-save", // Set the url
  thumbnailWidth: 80,
  thumbnailHeight: 80,
  parallelUploads: 20,
  previewTemplate: previewTemplate,
  maxFilesize: 255,
  maxFiles: 1,
  autoQueue: false, // Make sure the files aren't queued until manually added
  previewsContainer: "#previews", // Define the container to display the previews
  clickable: ".fileinput-button", // Define the element that should be used as click trigger to select files.
  acceptedFiles: ".png,.jpg,.gif,.jpeg",
  dictFileTooBig:"image file exceeds ----", 
  autoProcessQueue: false,
});
  <div id="actions" class="row">
      <div class="col-lg-7">

        <!-- The fileinput-button span is used to style the file input field as button -->
        <span class="btn btn-success fileinput-button dz-clickable">
            <i class="glyphicon glyphicon-plus"></i>
            <span>Add files...</span>
        </span>
        <button type="submit" class="btn btn-primary start" >
            <i class="glyphicon glyphicon-upload"></i>
            <span>Start upload</span>
        </button>
        <button type="reset" class="btn btn-warning cancel">
            <i class="glyphicon glyphicon-ban-circle"></i>
            <span>Cancel upload</span>
        </button>
      </div>
  </div>

那么如何使用dropzone.js引导程序实现这一点呢?

dropzone有一个名为“AddFile”的事件

您可以在本文中阅读有关它支持的事件的更多信息

//从init配置中推荐的方法:
Dropzone.options.myAwesomeDropzone={
init:function(){
this.on(“addedfile”,函数(文件){alert(“Added file”);};
}
};
此代码可能适用于您:

var myDropzone=newdropzone(.container),{//使整个身体成为Dropzone
url:“/images save”,//设置url
指钉宽度:80,
拇指指甲高度:80,
并行上传:20,
预览模板:预览模板,
最大文件大小:255,
maxFiles:1,
autoQueue:false,//请确保在手动添加之前不会将文件排入队列
PreviewContainer:“#previews”//定义用于显示预览的容器
可单击:“.fileinput按钮”,//定义应用作单击触发器以选择文件的元素。
acceptedFiles:“.png、.jpg、.gif、.jpeg”,
dictFileTooBig:“图像文件超过----”,
自动处理队列:false,
init:function(){
this.on(“addedfile”,函数(文件){alert(“Added file”);};
}
});
你看过文件了吗?