“upload de arquivo múltiplo html” Respostas de código

upload de arquivo múltiplo html

<form action="/action_page.php" enctype="multipart/form-data">
  <label for="images">Select images:</label>
  <input type="file" name="images[]" id="images" accept="image/*" multiple="multiple" id="product-photo-add">
  <input type="submit">
</form>
abed.in

upload de arquivo múltiplo html

<form action="/action_page.php">
  <label for="files">Select files:</label>
  <input type="file" id="files" name="files" multiple><br><br>
  <input type="submit">
</form>
Bad Booby

Upload de vários arquivos

<?php

  

namespace App\Http\Controllers;

  

use Illuminate\Http\Request;

use App\Models\File;

  

class FileController extends Controller

{

    /**

     * Display a listing of the resource.

     *

     * @return \Illuminate\Http\Response

     */

    public function index()

    {

        return view('fileUpload');

    }

    

    /**

     * Display a listing of the resource.

     *

     * @return \Illuminate\Http\Response

     */

    public function store(Request $request)

    {

        $request->validate([

            'files' => 'required',

            'files.*' => 'required|mimes:pdf,xlx,csv|max:2048',

        ]);

      

        $files = [];

        if ($request->file('files')){

            foreach($request->file('files') as $key => $file)

            {

                $fileName = time().rand(1,99).'.'.$file->extension();  

                $file->move(public_path('uploads'), $fileName);

                $files[]['name'] = $fileName;

            }

        }

  

        foreach ($files as $key => $file) {

            File::create($file);

        }

     

        return back()

                ->with('success','You have successfully upload file.');

   

    }

}
Zany Zebra

Respostas semelhantes a “upload de arquivo múltiplo html”

Perguntas semelhantes a “upload de arquivo múltiplo html”

Procure respostas de código populares por idioma

Procurar outros idiomas de código