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

177
Views
Rechazo no controlado (error): el archivo proporcionado no es una imagen
  • aquí estoy subiendo un archivo usando formik en reaccionar js

  • Cuando se carga el archivo, la validación de tamaño funciona, pero la validación de tipo no funciona

  • Aquí está mi código Si alguien puede ayudarme, entonces es realmente útil para mí.

     const SUPPORTED_FORMATS = ["image/jpg", "image/jpeg","image/png"]; const onFileChange = async (file) => { const options = {maxSizeMB: 1, maxWidthOrHeight: 500, useWebWorker: true} const compressedFile =await imageCompression(file, options) console.log(`------- Compressed File Size ${compressedFile.size / 1024} KB -------`) var formData = new FormData() formData.append('file', compressedFile) var url = URL.BASE + URL.STORAGE_UPLOAD + 'profileImage' var result = await post(url, formData, 'multipart/form-data') if (result.is_success === false) { addNotification(result.error_message, 'danger'); } else{ var url= reader.readAsDataURL(file) reader.readAsDataURL(file) reader.onloadend = function (e) { setSelectedImgUrl(reader.result); setProfileImage(result.data.fileName); } .bind(this) } } profileImgUrl: Yup .mixed() .nullable() .notRequired() .test( "filesize", requiredMessages.file_size_validation, (file) => !file || (file && file.size <= 2000000) ) .test( "fileformat", requiredMessages.file_type_validation, (file) => !file || (file && SUPPORTED_FORMATS.includes(file.type)) ), <input className="fileInput hidden" type="file" name="profileImgUrl" id="profileImgUrl" accept="image/* onBlur={handleBlur} onChange={(event) => { setFieldValue("profileImgUrl",event.target.files[0])onFileChange(event.target.files[0])}}/>`
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Establece el tamaño máximo en la declaración de opciones. No configuró los tipos permitidos.

 const options = {maxSizeMB: 1, maxWidthOrHeight: 500, useWebWorker: true}

Prueba esto (verificaría dos veces si es .jpg o jpg ya que no recuerdo la sintaxis):

 const filesFormats = [".jpg", ".gif"]; const isRightFormat = filesFormats.includes(file.type);
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!