【发布时间】:2014-01-09 02:44:24
【问题描述】:
这是我上传图片的代码,如果我将表单操作作为同一服务器,它工作正常
如果我对不同的服务器采取行动,则无法正常工作
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 将文件上传到不同的服务器?
【问题讨论】:
标签: javascript jquery node.js cross-domain dropzone.js