Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

123
Views
Enviar objeto y lista de imágenes al servidor en Reactjs

Estoy usando Reactjs en la interfaz.

Configuré la imagen de perfil para indicar con este código

 handleImageChange = (event) => { event.preventDefault(); var file = event.target.files[0]; var reader = new FileReader(); reader.readAsDataURL(file); reader.onloadend = function (e) { this.setState({ profilePicture: e.target.result //don't know how it is working }); }.bind(this); }

y puedo obtener una vista previa del archivo de imagen:

 <img src={this.state.profilePicture} alt="img"/>

Quiero enviar estos datos al servidor:

 data = { 'profilePicture': anImageFile,//this.state.profilePicture 'photos': [anotherImage, anotherImage2, anotherImage3], 'personal_info': { 'name': 'User Name', 'anyList': [1,2,3] } }

¿Puedo hacerlo usando fetch?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Simplemente puedes hacer esto:

 handleImageChange = (event) => { this.setState({profilePicture: event.target.files[0]}); }

Función de renderizado

 <img src={URL.createObjectURL(this.state.profilePicture)} alt="img"/>

Y enviar el objeto de datos tal como es.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!