相关疑难解决方法(0)

Angular中的文件上传?

我知道这是一个普遍的问题,但我没有在Angular 2上传文件.我试过了

1)http://valor-software.com/ng2-file-upload/

2)http://ng2-uploader.com/home

......但失败了.有人在Angular上传过文件吗?你用了什么方法?怎么办?如果提供任何示例代码或演示链接,我们将非常感激.

file-upload angular2-http angular

160
推荐指数
7
解决办法
23万
查看次数

角度文件上传

我是Angular的初学者,我想知道如何创建Angular 5 文件上传部分,我试着找到任何教程或文档,但我什么都没看到.对此有何看法?我正在尝试ng4文件,但它不适用于Angular 5

typescript angular

127
推荐指数
11
解决办法
23万
查看次数

如何使用Typescript和Angular 4显示图像

我对打字稿和网页开发很新,所以如果我的代码很糟糕,我很抱歉.无论如何,我在显示配置文件图片上传的"预览图像"时遇到问题.我正在使用ng2-file-upload将我的图像上传到服务器,该部分工作正常.在我点击上传按钮之前,我想在选择后立即在页面上显示所选图像.目前我试图通过从HTMLImageElement检索src属性来显示图像,但src属性似乎是空的.

import { Component, OnInit } from '@angular/core';
import {  FileUploader } from 'ng2-file-upload/ng2-file-upload';

const URL = 'http://localhost:4200/api/upload';

@Component({
  selector: 'app-view-profile',
  templateUrl: './view-profile.component.html',
  styleUrls: ['./view-profile.component.css']
})
export class ViewProfileComponent implements OnInit {

  constructor() { }
  public uploader: FileUploader = new FileUploader({url: URL, itemAlias: 'newProfilePicture'});
  title: string;
  previewImage: any;
  tempImage: any;
  source: string;

  imagePreview(input) 
  {
      document.getElementById("previewImage").style.display="block";
      
        console.log("Image is selected")
        this.previewImage = document.getElementById("previewImage");
        console.log(this.previewImage);
        
        this.source = (<HTMLImageElement>document.getElementById('previewImage')).src
        console.log("Image Source: " + this.source + " Should be inbetween here");
        
      
      //var reader = new …
Run Code Online (Sandbox Code Playgroud)

html5 typescript angular

8
推荐指数
2
解决办法
3万
查看次数

标签 统计

angular ×3

typescript ×2

angular2-http ×1

file-upload ×1

html5 ×1