Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ionic-framework/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 上载在数据库中插入值,将文件存储在文件夹中,但不会播放该文件_Angular_Ionic Framework - Fatal编程技术网

Angular 上载在数据库中插入值,将文件存储在文件夹中,但不会播放该文件

Angular 上载在数据库中插入值,将文件存储在文件夹中,但不会播放该文件,angular,ionic-framework,Angular,Ionic Framework,您好,我编写了一个脚本,将文件上载到文件夹,将值存储在db中,然后显示它。所有这些都正常,文件上传到文件夹中,值插入数据库中,显示如所需,但问题是,当我播放文件mp3时,不播放,它表示文件损坏或扩展名错误。文件没有损坏,在我开始上传过程之前播放 ts html 选择文件 提交 有什么答案吗?我想问题出在formData上 onSubmit() { let loader = this.loadingCtrl.create({ spinner: 'crescent', d

您好,我编写了一个脚本,将文件上载到文件夹,将值存储在db中,然后显示它。所有这些都正常,文件上传到文件夹中,值插入数据库中,显示如所需,但问题是,当我播放文件mp3时,不播放,它表示文件损坏或扩展名错误。文件没有损坏,在我开始上传过程之前播放

ts

html


选择文件
提交

有什么答案吗?我想问题出在formData上
   onSubmit() {

let loader = this.loadingCtrl.create({
    spinner: 'crescent',
    dismissOnPageChange: true
});

loader.present();
this.media.audioFile = this.fileData;
this.media.browser = true;
const media = new FormData();
media.append('file', this.fileData);
this.userData.uploadAudio(this.media) 
.map(res => res.json())
.subscribe(data => {
    loader.dismiss(); 


    if (data.success) {
        swal({
            icon: "success",
            text: data.message,
            buttons: {
                visible: false
            }
        });
    }
    else {
        swal({
            icon: "error",
            text: data.error,
            buttons: {
                visible: false
            }
        });
    }
},
err => {
    loader.dismiss();
    alert('An error occurred, please check your internet connection');
});
   }
  <div class="container">
<div class="row">
    <div class="col-md-6 offset-md-3">
        <h3>Choose File</h3>
        <form (ngSubmit)="onSubmit()">
            <div class="form-group">
                <input type="file" name="file"  />
            </div>
            <div class="form-group">
                <button class="btn btn-primary">Submit</button>
            </div>
        </form>
    </div>
</div>