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

383
Visualizações
How can i get the correct file extension in laravel 5.4

When I upload a csv file in laravel 5.4, I get 'txt' as the extension. Is there something I'm missing?

View

{!! Form::open(['url' => 'transaction/save', 'files' => true]) !!}

{!! Form::file('batch'); !!}

{!! Form::submit('Upload') !!}

{!! Form::close() !!}

Controller

public function saveBatch(Request $request)
 {
        $file = $request->batch;
        $path = $request->batch->extension();

        dd($path);
 }
over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

You need to move the file first, if you don't then the file is actually a temp file with no extension. You could also use:

 $request->batch->getClientOriginalExtension();

This would return the original filename's extension. More methods at: http://api.symfony.com/3.0/Symfony/Component/HttpFoundation/File/UploadedFile.html

over 4 years ago · Santiago Trujillo Relatório

0

The best way to get the extension of uploaded file: (If file input name is file)

$extension = $request->file->extension();
over 4 years ago · Santiago Trujillo Relatório
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