2016-01-21 45 views
0

我想使用dropzone.js上傳圖像文件,並且使用該功能成功上傳了它。我需要設置上傳文件的限制,限制應該動態設置。我試圖通過在js中的「maxFiles」變量上插入php代碼來改變dropzone.js中的限制,但是我失敗了。更改dropzone.js的默認功能性

難道你們中的任何人都可以幫我解決這個問題嗎? 我已附加dropzone.js的默認值我需要更改maxFiles的值動態地向我建議可能的解決方案。 預先感謝您像場爲您的ID

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.", 
+0

我想你會在你的php文件中創建一個全局JavaScript變量,它每次都會加載:並使用你的腳本變量在dropzone js –

+0

好吧讓我試試 –

+0

它的工作與否 –

回答

0
<script type="text/javascript"> 
Dropzone.options.yourid={ 
    maxFiles:5 
}; 
</script> 

保持ID通過該ID的腳本中,併爲您需要更改,並通過這種方法,我們可以改變輸入值的字段賦值dropzone.js的默認功能