ng文件上传中断在Firefox上
ng-file-upload breaks on Firefox
我在AngularJS应用程序中使用ng文件上传,它在Chrome和Safari中运行良好,但在Firefox中坏了,我得到了控制台中的Error: Argument 2 of FormData.append does not implement interface Blob.
消息。
其他人有这个问题吗?
包含指令的html代码段:
<label class="article-field-label" for="article_description">Imagens</label>
<div class="file-upload-container">
<a class="btn btn-default cancel-file-upload-button" ng-click="cancelPic(1)"><span>×</span></a>
<div class="button thumbnail-placeholder" ngf-select ng-file-select="onFileSelect($files)"
ng-model="article.filesAttachments.file1" name="file" type="file"
ngf-pattern="'image/*'" ngf-accept="'image/*'" ngf-max-size="5MB" ngf-min-height="100"
ngf-resize="{width: 100, height: 100}">
<img ngf-src="thumbnailImage(1)">
</div>
</div>
以及我向服务器发出POST请求的服务:
sendPayload = function(formData, method, url) {
var options;
options = {
url: url,
method: method,
file: formData.filesAttachments,
headers: { 'Content-Type': 'application/json' },
fields: {
article: {
title: formData.title,
price: formData.price,
user_id: formData.user_id,
category: formData.category,
article_state: formData.article_state,
description: formData.description,
city: formData.city,
article_id: formData.article_id
}
}
};
if(method=='POST'){
return Upload.upload(options).success(function(data, status){
if(status === 201) {
var file = formData.filesAttachments
angular.forEach(file, function(file){
file.upload = Upload.upload({
url: '/articles/' + data.article_id + '/attachments.json',
file: file,
headers: { 'Content-Type': 'application/json' },
method: 'POST'
})
})
}
}).success(function(data, status){
latestArticleCreatedID = data.article_id;
}).error(function(data, status) {
console.log("Failed" + status);
});
}
}
所以我的问题的解决方案是基于Github上的这条评论来更改
file: formData.filesAttachments
至
file: new Blob([formData.filesAttachments])
相关文章:
- 为什么这在IE中的工作方式与在Firefox中不同
- JS可以在Chrome中工作,但不能在Firefox中工作
- createElement("a") - FireFox JavaScript
- 为什么javascript:void(0)在Firefox中不起作用
- Facebook登录按钮没有'不能在Firefox上工作
- 高亮显示与数组字符串一起使用时文本插件中断
- jpm的默认Firefox路径没有'不起作用
- 重载JS'firefox中的对象原型
- AngularJS ui路由器html5模式中断路由
- Ajax调用在Firefox中不会自动响应
- ng文件上传中断在Firefox上
- Firefox操作系统-在物理硬件上中断XMLHttpRequest数组缓冲区请求
- Firefox操作系统模拟器中的Uint8Array/Uint16Array转换是否已中断
- 当使用css FireFox调整大小时,Flowplayer会中断
- Javascript函数在chrome和safari中工作,但在Firefox中中断
- 加载页面时连接中断- Firefox - Firebase - signInWithPopup()
- 为什么Kinetic 3's Firefox中的文本中断
- Firefox中的表单动态中断
- Firefox 无法识别视频 src 是否被中断
- 套接字.刷新时firefox连接中断