“Tutoriel de téléchargement de fichiers multiples de Laravel 9” Réponses codées

Tutoriel de téléchargement de fichiers multiples de Laravel 9

<?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

Tutoriel de téléchargement de fichiers multiples de Laravel 9

<?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

Tutoriel de téléchargement de fichiers multiples de Laravel 9

<?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

Tutoriel de téléchargement de fichiers multiples de Laravel 9

<?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

Tutoriel de téléchargement de fichiers multiples de Laravel 9

<?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

Tutoriel de téléchargement de fichiers multiples de Laravel 9

<?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

Tutoriel de téléchargement de fichiers multiples de Laravel 9

<?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

Tutoriel de téléchargement de fichiers multiples de Laravel 9

<?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

Tutoriel de téléchargement de fichiers multiples de Laravel 9

<?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

Tutoriel de téléchargement de fichiers multiples de Laravel 9

<?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

Réponses similaires à “Tutoriel de téléchargement de fichiers multiples de Laravel 9”

Questions similaires à “Tutoriel de téléchargement de fichiers multiples de Laravel 9”

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code