“Unggah file Laravel” Kode Jawaban

Unggah file Laravel


    public function fileUploadPost(Request $request)

    {

        $request->validate([

            'file' => 'required|mimes:pdf,xlx,csv|max:2048',

        ]);

  

        $fileName = time().'.'.$request->file->extension();  

   

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

   

        return back()

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

            ->with('file',$fileName);

   

    }
kashi knight

unggahan file Laravel

<?php

   

namespace App\Http\Controllers;

  

use Illuminate\Http\Request;

  

class FileUploadController extends Controller

{

    /**

     * Display a listing of the resource.

     *

     * @return \Illuminate\Http\Response

     */

    public function fileUpload()

    {

        return view('fileUpload');

    }

  

    /**

     * Display a listing of the resource.

     *

     * @return \Illuminate\Http\Response

     */

    public function fileUploadPost(Request $request)

    {

        $request->validate([

            'file' => 'required|mimes:pdf,xlx,csv|max:2048',

        ]);

  

        $fileName = time().'.'.$request->file->extension();  

   

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

   

        return back()

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

            ->with('file',$fileName);

   

    }

}
Nice Nightingale

file toko Laravel

$path = $request->file('avatar')->store(
    'avatars', 'public'
);
Faithful Fox

Laravel File mengunggah

$path = Storage::putFile('avatars', $request->file('avatar'));
Crazy Copperhead

Jawaban yang mirip dengan “Unggah file Laravel”

Pertanyaan yang mirip dengan “Unggah file Laravel”

Lebih banyak jawaban terkait untuk “Unggah file Laravel” di PHP

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya