我使用精美的上传器并且运行良好。现在,它即使成功上传也会重试。那么,我有四个文件而不是一个。
我的代码:
<!-- The element where Fine Uploader will exist. -->
<div id="qq-drop-zone">
<div id="fine-uploader"></div>
<span class="dragndrop">Drag and Drop</span>
</div>
<!-- Fine Uploader -->
<script src="/modules/fine-uploader/fine-uploader.min.js" type="text/javascript"></script>
<script type="text/template" id="qq-template">
<div class="qq-uploader-selector qq-uploader" qq-drop-area-text="Drop files here">
<div class="qq-total-progress-bar-container-selector qq-total-progress-bar-container">
<div role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" class="qq-total-progress-bar-selector qq-progress-bar qq-total-progress-bar"></div>
</div>
<div class="qq-upload-drop-area-selector qq-upload-drop-area" qq-hide-dropzone>
<span class="qq-upload-drop-area-text-selector"></span>
</div>
<div class="button qq-upload-button-selector qq-upload-button">
<div>Upload From Your</div>
</div>
<span class="qq-drop-processing-selector qq-drop-processing">
<span>Processing dropped files...</span>
<span class="qq-drop-processing-spinner-selector qq-drop-processing-spinner"></span>
</span>
<ul class="qq-upload-list-selector qq-upload-list" aria-live="polite" aria-relevant="additions removals">
<li class="clearfix">
<img class="qq-thumbnail-selector" qq-max-size="100" qq-server-scale>
<div class="qq-progress-bar-container-selector">
<div role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" class="qq-progress-bar-selector qq-progress-bar"></div>
</div>
<span class="qq-upload-spinner-selector qq-upload-spinner"></span>
<div class="form">
<div class="input_block caption">
<label for="caption">Caption</label>
<input type="text" class="caption_input" data-key="title" placeholder="" />
</div>
<div class="input_block qq-hide">
<span class="qq-edit-filename-icon-selector qq-edit-filename-icon" aria-label="Edit filename"></span>
</div>
</div>
<div class="file_data">
<span class="qq-upload-file-selector qq-upload-file"></span>
<input class="qq-edit-filename-selector qq-edit-filename" tabindex="0" type="text">
<span class="qq-upload-size-selector qq-upload-size"></span>
</div>
<button type="button" class="ghost button qq-btn qq-upload-cancel-selector qq-upload-cancel">Cancel</button>
<button type="button" class="ghost button qq-btn qq-upload-retry-selector qq-upload-retry">Retry</button>
<button type="button" class="button qq-btn qq-upload-delete-selector qq-upload-delete">Delete</button>
<span role="status" class="qq-upload-status-text-selector qq-upload-status-text"></span>
</li>
</ul>
<dialog class="qq-alert-dialog-selector">
<div class="qq-dialog-message-selector"></div>
<div class="qq-dialog-buttons">
<button type="button" class="button qq-cancel-button-selector">Close</button>
</div>
</dialog>
<dialog class="qq-confirm-dialog-selector">
<div class="qq-dialog-message-selector"></div>
<div class="qq-dialog-buttons">
<button type="button" class="ghost button qq-cancel-button-selector">No</button>
<button type="button" class="button qq-ok-button-selector">Yes</button>
</div>
</dialog>
<dialog class="qq-prompt-dialog-selector">
<div class="qq-dialog-message-selector"></div>
<input type="text">
<div class="qq-dialog-buttons">
<button type="button" class="ghost button qq-cancel-button-selector">Cancel</button>
<button type="button" class="button qq-ok-button-selector">Ok</button>
</div>
</dialog>
</div>
</script>
<script>
var dragAndDropModule = new qq.DragAndDrop({
dropZoneElements: [document.getElementById('qq-drop-zone')],
classes: {
dropActive: "dragover"
},
callbacks: {
processingDroppedFiles: function() {},
processingDroppedFilesComplete: function(files, dropTarget) {
fineUploaderBasicInstance.addFiles(files); //this submits the dropped files to Fine Uploader
}
}
}),
fineUploaderBasicInstance = new qq.FineUploader({
debug: true,
element: document.getElementById('fine-uploader'),
request: {
endpoint: '/ajax/fine-uploader.php'
},
retry: {
enableAuto: true
}
});
</script>
希望有帮助
答案 0 :(得分:1)
XHR responseText中有额外的文本使JSON无效。如果没有有效的响应,它会注册为失败的上传并启动重试。我摆脱了额外的文字,它再次起作用。