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

270
Views
La validación de imágenes de Laravel solo acepta archivos .png

Agregué un formulario para cargar el archivo de imagen y lo validé, la carga del archivo acepta solo el archivo .png . Cuando elijo jpg,jpeg u otros formatos, el campo de mensaje de error debe ser una imagen.

Laravel versión Versión 5.8.38

Mi método de controlador

 public function store() { $data = request()->validate([ 'caption' => 'required', 'image' => 'required | image' ]); Post::create($data); }

Mi vista

 <form action="/p" enctype="multipart/form-data" method="POST"> @csrf <div class="row"> <label for="image" class="col-md-4 col-form-label">Post Image</label> <input type="file" class="form-control-file" id="image" name="image"> @error('image') <strong style="color: #e3342f;font-size:80%">{{ $message }}</strong> @enderror </div> </form>
over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

public function store() { $data = request()->validate([ 'caption' => 'required', 'image' => 'required|file|mimes:jpeg,jpg,png' ]); Post::create($data); }
over 4 years ago · Santiago Trujillo Report

0

"image"=>'image | required | mimes:jpeg,png,jpg,gif,svg | max:2048',

en tu causa puedes elegir mimes: png

over 4 years ago · Santiago Trujillo 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!