【发布时间】:2016-01-21 09:57:46
【问题描述】:
我正在尝试使用 dropzone.js 上传图像文件,并且我已经使用该功能成功上传了它。我需要设置上传文件的限制,该限制应该是动态设置的。我试图通过在 js 内的“maxFiles”变量上插入 php 代码来更改 dropzone.js 中的限制,但我失败了。
你们中的任何人都可以帮助我提供一个可能的解决方案来执行此操作。 我已经附加了 dropzone.js 的默认值我需要动态更改 maxFiles 的值建议我可能的解决方案。 提前谢谢你
url: '?do=uploadimage',
method: "post",
withCredentials: false,
parallelUploads: 2,
uploadMultiple: false,
maxFilesize: 1,
paramName: "file",
createImageThumbnails: true,
maxThumbnailFilesize: 1,
thumbnailWidth: 120,
thumbnailHeight: 120,
filesizeBase: 1000,
maxFiles: null,
params: {},
clickable: true,
ignoreHiddenFiles: true,
acceptedFiles: null,
acceptedMimeTypes: null,
autoProcessQueue: true,
autoQueue: true,
addRemoveLinks: true,
previewsContainer: null,
hiddenInputContainer: "body",
capture: null,
dictDefaultMessage: "Drag Files here or Click to Upload",
dictFallbackMessage: "Your browser does not support drag'n'drop file uploads.",
dictFallbackText: "Please use the fallback form below to upload your files like in the olden days.",
dictFileTooBig: "File is too big ({{filesize}}MiB). Max filesize: {{maxFilesize }}MiB.",
dictInvalidFileType: "You can't upload files of this type.",
dictResponseError: "Server responded with {{statusCode}} code.",
dictCancelUpload: "Cancel upload",
dictCancelUploadConfirmation: "Are you sure you want to cancel this upload?",
dictRemoveFile: "Remove",
dictRemoveFileConfirmation: null,
dictMaxFilesExceeded: "You can not upload any more files.",
【问题讨论】:
-
我认为您在每次加载的 php 文件中创建全局 javascript 变量,例如: 并在 dropzone js 中使用您的脚本变量
-
我尝试了一个新的,看看我的答案
标签: javascript php image dropzone.js