我想完成上传文件拖动:我正在使用ng2-file-upload版本1.2.1以及以下代码片段:
app.module.ts:
import { FileUploadModule } from 'ng2-file-upload/ng2-file-upload';
..
imports: [
FileUploadModule
]
Run Code Online (Sandbox Code Playgroud)
component.ts:
import { FileUploader } from 'ng2-file-upload/ng2-file-upload';
...
class AppXYZComponent{
private uploader: FileUploader = new FileUploader({ url: 'blah.com' });
public hasBaseDropZoneOver:boolean = false;
//public hasAnotherDropZoneOver:boolean = false;
public fileOverBase(e:any):void {
console.log("hasBaseDropZoneOver", e);
this.hasBaseDropZoneOver = e;
}
}
Run Code Online (Sandbox Code Playgroud)
app.component.html:
<div class="well" ng2FileDrop [uploader]="uploader" [ngClass]="{'another-file-over-class': hasBaseDropZoneOver}"
(fileOver)="fileOverBase($event)"
>
Drop CSV here
</div>
Run Code Online (Sandbox Code Playgroud)
函数fileOverBase在拖动时成功调用,事件e打印为true.现在我如何获得拖动文件的对象?
angular-file-upload angular2-directives ng2-file-upload angular
标题是我的问题,我该如何使用base64发送图像ng2-file-upload?
我在Angular 4中的代码:
public uploader: FileUploader = new FileUploader({
url: URL,
allowedMimeType: ['application/pdf', 'image/jpeg', 'image/png'],
maxFileSize: 10 * 1024 * 1024, // 10 MB
queueLimit: 3,
disableMultipart: true,
});
Run Code Online (Sandbox Code Playgroud) 这是我的代码。我无法上传大小超过 1 mb 的任何文件,但我已将 maxFileSize 设置为 50mb,请帮忙,我做错了什么?
@Component({
moduleId: module.id,
//define the element to be selected from the html structure.
selector: 'NeedAnalysisConsult',
//location of our template rather than writing inline templates.
templateUrl: 'need-analysis-consultation.component.html',
})
export class NeedAnalysisConsultationComponent implements OnInit {
model:any={};
consultationDate: Date;
organisation: string;
devCode:String;
maxFileSize = 50 * 1024 * 1024;
//declare a property called fileuploader and assign it to an instance of a new fileUploader.
//pass in the Url to be uploaded to, and pass the itemAlais, …Run Code Online (Sandbox Code Playgroud) 我正在使用 ng2-file-upload 中的带有文件类型限制的文件上传器。但是,每次我使用 Internet Explorer 11 选择 png 文件时,它都不会添加到队列中。所有其他允许的文件类型均有效。这是带有文件选项的代码:
let uploadOptions: FileUploaderOptions;
if (navigator.userAgent.match(/Trident.*rv\:11\./)) {
uploadOptions = {
url: uploadUrl,
allowedFileType: ['xls', 'xlsx', 'doc', 'docx', 'pdf', 'gif', 'jpg', 'jpeg', 'png', 'odt', 'txt', 'ods'],
maxFileSize: 10 * 1024 * 1024
};
} else {
uploadOptions = {
url: uploadUrl,
allowedMimeType: ['application/pdf',
'application/vnd.ms-excel',
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
'application/msword',
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
'application/vnd.oasis.opendocument.text',
'application/vnd.oasis.opendocument.spreadsheet',
'image/gif',
'image/jpeg',
'image/png'
],
maxFileSize: 10 * 1024 * 1024
};
}
this.uploader = new FileUploader(uploadOptions);
this.uploader.onCompleteAll = () => {
this.editStateService.documentAdded('player', 'document');
this.documentListUpdated.emit(); …Run Code Online (Sandbox Code Playgroud)