這裏是我的代碼上傳圖像,它工作正常,如果我給的形式行動同一個服務器dropzone.js圖片上傳到不同的服務器(跨域)
如果我給行動不同的服務器不工作
HTML:
<div id="dropzone">
<form action="http://localhost:8080/stardom/api/v1/image" class="dropzone">
<input type="hidden" name="album_id" value="" id="album_id" />
<div class="fallback">
<input name="file" type="file" multiple="" />
</div>
</form>
</div>
JS:
$(".dropzone").dropzone({
paramName: "file", // The name that will be used to transfer the file
maxFilesize: 2, // MB
acceptedMimeTypes : 'image/*',
addRemoveLinks : false,
dictDefaultMessage :
'<span class="bigger-150 bolder"><i class="icon-caret-right red"></i> Drop files</span> to upload \
<span class="smaller-80 grey">(or click)</span> <br /> \
<i class="upload-icon icon-cloud-upload blue icon-3x"></i>'
,
dictResponseError: 'Error while uploading file!',
//change the previewTemplate to use Bootstrap progress bars
previewTemplate: "<div class=\"dz-preview dz-file-preview\">\n <div class=\"dz-details\">\n <div class=\"dz-filename\"><span data-dz-name></span></div>\n <div class=\"dz-size\" data-dz-size></div>\n <img data-dz-thumbnail />\n </div>\n <div class=\"progress progress-small progress-success progress-striped active\"><span class=\"bar\" data-dz-uploadprogress></span></div>\n <div class=\"dz-success-mark\"><span></span></div>\n <div class=\"dz-error-mark\"><span></span></div>\n <div class=\"dz-error-message\"><span data-dz-errormessage></span></div>\n</div>",
complete : function(){
if (this.getUploadingFiles().length === 0 && this.getQueuedFiles().length === 0) {
loadImages();
}
}
});
問:我怎樣才能讓dropzone.js上傳文件到不同的服務器?
我正在使用節點,在我的代碼中已經有'Access-Control-Allow-Origin'*「',但我已經有了解決方案,我將它更新爲答案 –