问题标签 [ng2-file-upload]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
2 回答
696 浏览

angular - Angular 6 ng2 文件上传无法将队列的属性读取为未定义

使用 Angular 6 通过 Valor Software 的 ng2 文件上传器将图片上传到服务器并不断出错。问题是,我之前在 Visual Studio Code 中使用过 ng2 文件上传器,它运行良好。这个项目是从带有 .NET Core 和 Angular 包的 Visual Studio 2017 开始的,我想知道这是否与为什么它的运行方式不同(或几乎一样容易)有关。

"ng2-file-upload": "^1.3.0"在 package.json 中使用。

我已经import { FileUploadModule } from 'ng2-file-upload';在我的模块的导入数组中导入并声明了。

我的html:

我的组件.ts:

当 html 渲染一切混乱时,我总是会遇到这些错误。

在此处输入图像描述

0 投票
1 回答
324 浏览

angular - Angular 6 ng2-file-upload 带文件的发送列表

我的 Angular 项目中有这段代码,并使用 ng2-file-upload 来上传图像。

当我尝试使用文件发送数据时,服务器端的 productPropertyList 是空的,而它在发送之前有数据。

如何发送数组?

0 投票
0 回答
378 浏览

angular - 使用 ng2-file-upload 在云端上传图像时出现问题

我将带有角度的照片上传到后端(Core 2.2),但出现错误。当我选择照片并单击上传时,这就是我得到的: 照片 1

而且我不知道为什么我得到: POST http://localhost:4200/ undefinedusers /4/photos 它应该只是没有undefined的用户

当我点击 Zone.js.3372 这就是我得到的: 照片 2 当我使用 Postman 时一切正常,图片保存在 cloudinary 网站上,所以问题出在客户端的某个地方。

这是将图像上传到服务器的部分。

这是html:

0 投票
1 回答
228 浏览

angular - 如何将 ng2-file-upload 与设计令牌身份验证一起使用?

我目前正在尝试将 ng2-file-upload 与设计令牌身份验证一起使用。:https ://devise-token-auth.gitbook.io/devise-token-auth/conceptual 。文件上传器目前直接处理 http 请求,因此,我没有使用 angular token rest api 服务类来上传对象:https ://angular-token.gitbook.io/docs/session-management 。相反,我必须手动设置与身份验证令牌一致的标头。

HTML 文件

上传本身成功完成,但上传后,我看到会话中的访问令牌不再起作用。我认为这是因为我使用设计令牌身份验证来根据请求更新令牌,并且我没有将其设置到我的本地存储中。如何手动检索响应标头中的令牌并将其设置到浏览器的本地存储中?(否则在正常请求中由角度令牌处理)

0 投票
1 回答
89 浏览

angular - 无法上传 `.flv` - 使用 ng2-file-upload 的文件

这是我的哑剧类型:

当我尝试上传.flv- 文件时,出现错误invalid file type。我的声明有什么问题?有人帮我吗?

所有其他文件类型都工作正常。

this.fileUploader = new FileUploader( { allowedMimeType: this.allowedMimeType, maxFileSize: this.singleMaxFileSize, removeAfterUpload: true, queueLimit: 1 } );

0 投票
1 回答
551 浏览

angular - angular ng2-file-upload 获取上传的文件块

我正在使用 ng2-file-upload 来上传任何类型的图像和文件,常规示例工作正常,但我实际上想检索上传文件的 blob 而不是使用常规处理,因为我要去在服务器端做我自己的处理。谁能告诉我选择后如何上传文件的blob?

我想做的是这样的:

0 投票
1 回答
224 浏览

angular - 如何设置上传的“最小”文件大小

我正在使用ng2-file-upload来满足我的 Angular 应用程序的文件上传要求。在这个指令中,我可以设置maxFileSize- 但问题是,有一种方法可以只上传空文件。所以我正在寻找一种解决方案来防止空文件上传。

有没有办法测试它并抛出错误?或者我可以设置上传的最小尺寸吗?

这是我的配置:

0 投票
2 回答
1014 浏览

javascript - 如何以角度适当地更改 ng2-file-uploader 的文件名

我想通过 ng2-file-uploader 以角度更改图像的名称,然后将其传递给 node.js 中的 multer。

一切正常。我能够接收到图像,并且它存储在服务器端的上传目录中。只是我不知道在哪里更改图像名称。我在 onCompleteItem 方法中尝试过,但没有。这是一些代码:

我只想更改名称,以便可以将它与我拥有的其他输入值一起存储在我的数据库中。

0 投票
0 回答
675 浏览

javascript - ng2-file-upload 单个请求 clearQueue() 不起作用

上传者在一个请求中包含多个文件,因此在使用 clearQueue() 获得响应后自定义文件上传不起作用,仅删除单个文件

core.js:3926 错误类型错误:无法读取 FileUploaderCustom.push../node_modules/ng2-file-upload/file-upload/file-uploader.class.js.FileUploader.cancelItem 处未定义的属性“中止”(file-uploader .class.js:112) 在 FileItem.push../node_modules/ng2-file-upload/file-upload/file-item.class.js.FileItem.cancel (file-item.class.js:38) 在 FileUploaderCustom .push../node_modules/ng2-file-upload/file-upload/file-uploader.class.js.FileUploader.removeFromQueue (file-uploader.class.js:85) 在 FileItem.push../node_modules/ng2- File-upload/file-upload/file-item.class.js.FileItem.remove (file-item.class.js:41) 在 FileUploaderCustom.push../node_modules/ng2-file-upload/file-upload/file -uploader.class.js.FileUploader.clearQueue (file-uploader.class.js:92) 在 FileUploaderCustom.uploaderOnward。onSuccessItem (mandate-initial.component.ts:267) 在 FileUploaderCustom.push../node_modules/ng2-file-upload/file-upload/file-uploader.class.js.FileUploader._onSuccessItem (file-uploader.class.js :396) 在 XMLHttpRequest.xhr.onload [as __zone_symbol__ON_PROPERTYload] (fileUploader.ts:71) 在 XMLHttpRequest.wrapFn (zone.js:1255) 在 ZoneDelegate.invokeTask (zone.js:431)

自定义文件上传 .ts

回应

0 投票
3 回答
8269 浏览

javascript - 如何使用角度图像上传显示图像缩略图

我正在使用ng2-file-upload上传图片。一切正常,但在我选择图像后,它会显示选定的图像缩略图。

请查看我的stackblitz 链接

提前致谢