Configuration options | ||
Option | Description | 描述 |
url default: null | Has to be specified on elements other than form (or when the form doesn’t have an action attribute). You can also provide a function that will be called with files and must return the url (since v3.12.0) | 配置选项描述必须在除表单之外的元素上指定(或者在表单没有action属性时)。您还可以提供将使用文件调用的函数,并且必须返回url(自v3.12.0起) |
method default: “post” | Can be changed to put if necessary. You can also provide a function that will be called with files and must return the method (since v3.12.0). | 必要时可以更改为put。您还可以提供将使用文件调用的函数,并且必须返回该方法(自v3.12.0起)。 |
withCredentials default: false | Will be set on the XHRequest. | 将在XHRequest上设置。 |
timeout default: 30000 | The timeout for the XHR requests in milliseconds (since v4.4.0). | XHR请求的超时(以毫秒为单位)(自v4.4.0起)。 |
parallelUploads default: 2 | How many file uploads to process in parallel (See the Enqueuing file uploads* documentation section for more info) | 要并行处理多少文件上传(有关详细信息,请参阅排队文件上传*文档部分) |
uploadMultiple default: false | Whether to send multiple files in one request. If this it set to true, then the fallback file input element will have the multiple attribute as well. This option will also trigger additional events (like processingmultiple). See the events documentation section for more information. | 是否在一个请求中发送多个文件。如果将其设置为true,则后备文件输入元素也将具有multiple属性。此选项还将触发其他事件(如processingofultiple)。有关更多信息,请参阅事件文档部分。 |
chunking default: false | Whether you want files to be uploaded in chunks to your server. This can’t be used in combination with uploadMultiple. See chunksUploaded for the callback to finalise an upload. | 是否要将文件以块的形式上传到服务器。这不能与uploadMultiple结合使用。请参阅chunksUploaded以获取回调以完成上传。 |
forceChunking default: false | If chunking is enabled, this defines whether every file should be chunked, even if the file size is below chunkSize. This means, that the additional chunk form data will be submitted and the chunksUploaded callback will be invoked. | 如果启用了分块,则定义是否应对每个文件进行分块,即使文件大小低于chunkSize也是如此。这意味着,将提交附加的块表单数据并调用chunksUploaded回调。 |
chunkSize default: 2000000 | If chunking is true, then this defines the chunk size in bytes. | 如果chunking为true,则以字节为单位定义块大小。 |
parallelChunkUploads default: false | If true, the individual chunks of a file are being uploaded simultaneously. | 如果为true,则同时上载文件的各个块。 |
retryChunks default: false | Whether a chunk should be retried if it fails. | 如果块失败,是否应该重试块。 |
retryChunksLimit default: 3 | If retryChunks is true, how many times should it be retried. | 如果retryChunks为true,则应重试多少次。 |
maxFilesize default: 256 | If not null defines how many files this Dropzone handles. If it exceeds, the event maxfilesexceeded will be called. The dropzone element gets the class dz-max-files-reached accordingly so you can provide visual feedback. | 如果不为null,则定义此Dropzone处理的文件数。如果超过,将调用maxfilesexceeded事件。 dropzone元素相应地获得了dz-max-files类,因此您可以提供视觉反馈。 |
paramName default: “file” | The name of the file param that gets transferred. NOTE: If you have the option uploadMultiple set to true, then Dropzone will append [] to the name. | 传输的文件参数的名称。注意:如果您将选项uploadMultiple设置为true,则Dropzone会将[]附加到名称。 |
createImageThumbnails default: true | Whether thumbnails for images should be generated | 是否应生成图像的缩略图 |
maxThumbnailFilesize default: 10 | In MB. When the filename exceeds this limit, the thumbnail will not be generated. | 以MB为单位。当文件名超过此限制时,将不会生成缩略图。 |
thumbnailWidth default: 120 | If null, the ratio of the image will be used to calculate it. | 如果为null,则将使用图像的比率来计算它。 |
thumbnailHeight default: 120 | The same as thumbnailWidth. If both are null, images will not be resized. | 与thumbnailWidth相同。如果两者都为null,则不会调整图像大小。 |
thumbnailMethod default: ‘crop’ | How the images should be scaled down in case both, thumbnailWidth and thumbnailHeight are provided. Can be either contain or crop. | 如果提供了thumbnailWidth和thumbnailHeight,则应如何缩小图像。可以是包含还是作物。 |
resizeWidth default: null | If set, images will be resized to these dimensions before being uploaded. If only one, resizeWidth or resizeHeight is provided, the original aspect ratio of the file will be preserved. The options.transformFile function uses these options, so if the transformFile function is overridden, these options don’t do anything. | 如果设置,图像将在上传之前调整为这些尺寸。如果只提供一个,resizeWidth或resizeHeight,则将保留文件的原始高宽比。options.transformFile函数使用这些选项,因此如果重写transformFile函数,则这些选项不会执行任何操作。 |
resizeHeight default: null | See resizeWidth. | 见resizeWidth。 |
resizeMimeType default: null | The mime type of the resized image (before it gets uploaded to the server). If null the original mime type will be used. To force jpeg, for example, use image/jpeg. See resizeWidth for more information. | 已调整大小的图像的mime类型(在上载到服务器之前)。如果为null,则将使用原始mime类型。例如,要强制使用jpeg,请使用image / jpeg。有关更多信息,请参阅resizeWidth。 |
resizeQuality default: 0.8 | The quality of the resized images. See resizeWidth. | 调整大小的图像的质量。见resizeWidth。 |
resizeMethod default: ‘contain’ | How the images should be scaled down in case both, resizeWidthand resizeHeight are provided. Can be either contain or crop. | 如果提供resizeWidthand resizeHeight,则应如何缩小图像。可以是包含还是作物。 |
filesizeBase default: 1000 | The base that is used to calculate the filesize. You can change this to 1024 if you would rather display kibibytes, mebibytes, etc… 1024 is technically incorrect, because 1024 bytes are 1 kibibyte not 1 kilobyte. You can change this to 1024 if you don’t care about validity. | 用于计算文件大小的基础。如果您希望显示kibibytes,mebibytes等,可以将其更改为1024 … 1024在技术上是不正确的,因为1024字节是1 kibibyte而不是1 KB。如果您不关心有效性,可以将其更改为1024。 |
maxFiles default: null | Can be used to limit the maximum number of files that will be handled by this Dropzone | 可用于限制此Dropzone将处理的最大文件数 |
headers default: null | An optional object to send additional headers to the server. Eg: { My-Awesome-Header: header value } | 用于将其他标头发送到服务器的可选对象。例如:{My-Awesome-Header:标题值} |
clickable default: true | If true, the dropzone element itself will be clickable, if falsenothing will be clickable. You can also pass an HTML element, a CSS selector (for multiple elements) or an array of those. In that case, all of those elements will trigger an upload when clicked. | 如果是,如果falsenothing可以点击,则dropzone元素本身将是可点击的。您还可以传递HTML元素,CSS选择器(用于多个元素)或其中的数组。在这种情况下,所有这些元素都会在单击时触发上传。 |
ignoreHiddenFiles default: true | Whether hidden files in directories should be ignored. | 是否应忽略目录中的隐藏文件。 |
acceptedFiles default: null | The default implementation of accept checks the file’s mime type or extension against this list. This is a comma separated list of mime types or file extensions. Eg.: image/*,application/pdf,.psd If the Dropzone is clickable this option will also be used asaccept parameter on the hidden file input as well. | accept的默认实现会根据此列表检查文件的mime类型或扩展名。这是一个以逗号分隔的mime类型或文件扩展名列表。如:图像/ *,应用程序/ PDF,.PSD如果可以单击Dropzone,则此选项也将用作隐藏文件输入的asaccept参数。 |
acceptedMimeTypes default: null | Deprecated! Use acceptedFiles instead. | 不推荐使用!请改用acceptedFiles。 |
autoProcessQueue default: true | If false, files will be added to the queue but the queue will not be processed automatically. This can be useful if you need some additional user input before sending files (or if you want want all files sent at once). If you’re ready to send the file simply call myDropzone.processQueue(). See the enqueuing file uploads documentation section for more information. | 如果为false,文件将被添加到队列中,但队列将不会自动处理。如果您在发送文件之前需要一些额外的用户输入(或者如果您想要一次发送所有文件),这将非常有用。如果您’重新准备发送文件只需调用myDropzone.processQueue()。有关详细信息,请参阅排队文件上载文档部分。 |
autoQueue default: true | If false, files added to the dropzone will not be queued by default. You’ll have to call enqueueFile(file) manually. | 如果为false,则默认情况下,添加到dropzone的文件不会排队。您必须手动调用enqueueFile(文件)。 |
addRemoveLinks default: false | If true, this will add a link to every file preview to remove or cancel (if already uploading) the file. The dictCancelUpload, dictCancelUploadConfirmation and dictRemoveFile options are used for the wording. | 如果为true,则会添加指向每个文件预览的链接以删除或取消(如果已上载)文件。 dictCancelUpload,dictCancelUploadConfirmation和dictRemoveFile选项用于措辞。 |
previewsContainer default: null | Defines where to display the file previews – if null the Dropzone element itself is used. Can be a plain HTMLElement or a CSS selector. The element should have the dropzone-previews class so the previews are displayed properly. | 定义显示文件预览的位置 - 如果为null,则使用Dropzone元素本身。可以是普通的HTMLElement或CSS选择器。该元素应具有dropzone-previews类,以便正确显示预览。 |
hiddenInputContainer default: “body” | This is the element the hidden input field (which is used when clicking on the dropzone to trigger file selection) will be appended to. This might be important in case you use frameworks to switch the content of your page. Can be a selector string, or an element directly. | 这是隐藏输入字段(在单击dropzone以触发文件选择时使用)的元素将附加到。如果您使用框架切换页面内容,这可能很重要。可以是选择器字符串,也可以是直接元素。 |
capture default: null | If null, no capture type will be specified If camera, mobile devices will skip the file selection and choose camera If microphone, mobile devices will skip the file selection and choose the microphone If camcorder, mobile devices will skip the file selection and choose the camera in video mode On apple devices multiple must be set to false. AcceptedFiles may need to be set to an appropriate mime type (e.g. image/, audio/, or video/*). | 如果为null,则不指定捕获类型如果摄像头,移动设备将跳过文件选择并选择摄像头如果是麦克风,移动设备将跳过文件选择并选择麦克风如果摄像机,移动设备将跳过文件选择并选择摄像机在视频模式下在Apple设备上,必须将multiple设置为false。 AcceptedFiles可能需要设置为适当的mime类型(例如image /,audio /或video / *)。 |
renameFilename default: null | Deprecated. Use renameFile instead. | 已过时。使用renameFile代替。 |
renameFile default: null | A function that is invoked before the file is uploaded to the server and renames the file. This function gets the File as argument and can use the file.name. The actual name of the file that gets used during the upload can be accessed through file.upload.filename. | 在将文件上载到服务器并重命名文件之前调用的函数。此函数将File作为参数,并可以使用file.name。可以通过file.upload.filename访问上载期间使用的文件的实际名称。 |
forceFallback default: false | If true the fallback will be forced. This is very useful to test your server implementations first and make sure that everything works as expected without dropzone if you experience problems, and to test how your fallbacks will look. | 如果为真,则会强制进行后备。这对于首先测试您的服务器实现非常有用,如果您遇到问题,请确保所有内容都按预期工作而不使用dropzone,并测试回退的外观。 |
to translate dropzone, you can provide these options: | ||
dictDefaultMessage default: see description | null | 删除任何文件之前使用的文本。 |
dictFallbackMessage default: see description | null | 替换默认消息文本的文本,不支持浏览器。 |
dictFallbackText default: see description | null | 将在后备表单之前添加的文本。如果您自己提供后备元素,或者此选项将被忽略。 |
dictFileTooBig default: see description | null | 如果文件大小太大。 {{filesize}}和{{maxFilesize}}将替换为相应的配置值。 |
dictInvalidFileType default: see description | null | 如果文件与文件类型不匹配。 |
dictResponseError default: see description | null | 如果服务器响应无效。 {{statusCode}}将替换为服务器状态代码。 |
dictCancelUpload default: see description | null | 如果addRemoveLinks为true,则用于取消上载链接的文本。 |
dictUploadCanceled default: see description | null | 手动取消上传时显示的文本 |
dictCancelUploadConfirmation default: see description | null | 如果addRemoveLinks为true,则取消上载时用于确认的文本。 |
dictRemoveFile default: see description | null | 如果addRemoveLinks为true,则用于删除文件的文本。 |
dictRemoveFileConfirmation default: see description | null | 如果不是,则在删除文件之前将提示用户。 |
dictMaxFilesExceeded default: see description | null | 如果maxFiles是st并且超出则显示。字符串{{maxFiles}}将替换为配置值。 |
dictFileSizeUnits default: see description | null | 允许您翻译不同的单位。以tb开头为TB,下到b为字节。 |
functions you can override to change or extend default behavior: | ||
init default: empty function | Called when dropzone initialized You can add event listeners here | 在dropzone初始化时调用您可以在此处添加事件侦听器 |
params default: function | Can be an object of additional parameters to transfer to the server, ora Function that gets invoked with the files, xhr and, if it’s a chunked upload, chunk arguments. In case of a function, this needs to return a map. The default implementation does nothing for normal uploads, but adds relevant information for chunked uploads. This is the same as adding hidden input fields in the form element. | 可以是传输到服务器的附加参数的对象,ora用文件调用的函数,xhr,如果是分块上传,则是块参数。如果是函数,则需要返回映射。 默认实现不会对正常上载执行任何操作,但会为分块上载添加相关信息。 这与在表单元素中添加隐藏的输入字段相同。 |
accept default: function | A function that gets a file and a done function as parameters. If the done function is invoked without arguments, the file is accepted and will be processed. If you pass an error message, the file is rejected, and the error message will be displayed. This function will not be called if the file is too big or doesn’t match the mime types. | 将文件和完成函数作为参数获取的函数。 如果在没有参数的情况下调用done函数,则文件被接受并将被处理。如果传递错误消息,则拒绝该文件,并显示错误消息。如果文件太大或与mime类型不匹配,则不会调用此函数。 |
chunksUploaded default: function | The callback that will be invoked when all chunks have been uploaded for a file. It gets the file for which the chunks have been uploaded as the first parameter, and the done function as second. done() needs to be invoked when everything needed to finish the upload process is done. | 在为文件上载所有块时将调用的回调。它将上传了块的文件作为第一个参数,并将done函数作为第二个参数。当完成上传过程所需的一切都完成后,需要调用done()。 |
fallback default: function | Gets called when the browser is not supported. The default implementation shows the fallback input field and adds a text. | 在不支持浏览器时调用。默认实现显示回退输入字段并添加文本。 |
resize default: function | Gets called to calculate the thumbnail dimensions. It gets file, width and height (both may be null) as parameters and must return an object containing:
Those values are going to be used by ctx.drawImage(). | 调用它来计算缩略图尺寸。 它获取文件,宽度和高度(两者都可以为null)作为参数,并且必须返回包含以下内容的对象: srcWidth&srcHeight(必需的) trgWidth&trgHeight(必需的) srcX&srcY(可选,默认为0) trgX&trgY(可选,默认为0) 这些值将由ctx.drawImage()使用。 |
transformFile default: function | Can be used to transform the file (for example, resize an image if necessary). The default implementation uses resizeWidth and resizeHeight(if provided) and resizes images according to those dimensions. Gets the file as the first parameter, and a done() function as the second, that needs to be invoked with the file when the transformation is done. | 可用于转换文件(例如,必要时调整图像大小)。 默认实现使用resizeWidth和resizeHeight(如果提供)并根据这些维度调整图像大小。 获取文件作为第一个参数,并将done()函数作为第二个参数,在转换完成时需要使用文件调用。 |
previewTemplate default: HTML template | A string that contains the template used for each dropped file. Change it to fulfill your needs but make sure to properly provide all elements. If you want to use an actual HTML element instead of providing a String as a config option, you could create a div with the id tpl, put the template inside it and provide the element like this: document .querySelector(‘#tpl’) .innerHTML | 包含用于每个删除文件的模板的字符串。更改它以满足您的需求,但请确保正确提供所有元素。 如果你想使用一个实际的HTML元素而不是提供一个String作为配置选项,你可以创建一个id为tpl的div,将模板放在其中并提供如下元素: document .querySelector( ‘#TPL’) .innerHTML |
dropzonejsz配置选项
最新推荐文章于 2021-03-24 01:51:18 发布