Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

368
Visualizações
If click submit data send ng2-file-upload

How can I make the images uploads go with the data when I click the send button. Now I have a problem in the fact that when you select images are immediately downloaded to the server and there is a post request to api. I use Rails 5 for api gallery.component.ts

 name: string;
  uploadFile: any;
  hasBaseDropZoneOver: boolean = false;
    uploadedFiles: any[] = [];
  options: Object = {
    url: 'http://localhost:3000/galleries'
  };
  sizeLimit = 2000000;

  handleUpload(data): void {
    if (data && data.response) {
      data = JSON.parse(data.response);
      this.uploadFile = data;
      this.name = this.uploadFile.filename;
    }
  }

  fileOverBase(e:any):void {
    this.hasBaseDropZoneOver = e;
  }

  beforeUpload(uploadingFile): void {
    if (uploadingFile.size > this.sizeLimit) {
      uploadingFile.setAbort();
      alert('File is too large');
    }
  }

shop.component.ts

                  id : number;

              owner_id :number;

            submit(user){
              user.owner_id= this.authTokenService.currentUserData.id;
              this.httpService.postData(user)
              .subscribe((data) => {this.receivedUser=data; this.done=true;this.router.navigate(['/profile'])});

    }
ngOnInit() {
  this.getUserShops(this.authTokenService.currentUserData.id)
    .subscribe((ownerShops) => {
      if (ownerShops.length > 0) {
        // User has at least 1 shop
this.router.navigate(['/profile'])
        console.log(ownerShops.id);
      } else {
        // User has no shops
      }
    })
}

shop.component.html

Name
            <div class="form-group">
                <label>About</label>
                <input class="form-control" type="text" name="about" [(ngModel)]="user.about" />
            </div>
                     <div class="form-group">
                <label>opening</label>
                <input class="form-control" type="text" name="opening" [(ngModel)]="user.opening" />
            </div>
                     <div class="form-group" >
                <label>closing</label>
                <input class="form-control" type="text" name="closing" [(ngModel)]="user.closing" />
            </div>
            <app-gallery> </app-gallery>
            <div class="form-group">
                <button class="btn btn-default" (click)="submit(user)">Send</button>
            </div>

gallery.component.html

<input type="file"
   ngFileSelect
   [options]="options"
   (onUpload)="handleUpload($event)"
   (beforeUpload)="beforeUpload($event)"
   multiple>
over 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda