“Unggah gambar di Laravel” Kode Jawaban

Unggah gambar di Laravel

$fileName = $file->storePublicly('images/media', [
            'disk' => 's3'
        ]);
Qurban Ali

Unggah gambar di Laravel

<?php
  
namespace App\Http\Controllers;
  
use Illuminate\Http\Request;
  
class ImageUploadController extends Controller
{
     /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function imageUpload()
    {
        return view('imageUpload');
    }
    
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function imageUploadPost(Request $request)
    {
        $request->validate([
            'image' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:2048',
        ]);
    
        $imageName = time().'.'.$request->image->extension();  
     
        $request->image->move(public_path('images'), $imageName);
  
        /* Store $imageName name in DATABASE from HERE */
    
        return back()
            ->with('success','You have successfully upload image.')
            ->with('image',$imageName); 
    }
}
Yucky Yak

Unggah gambar di Laravel

  $image= $request->image;
         $imageName=time().'.'.$image->getClientOriginalExtension();
         $request->image->move('chefsimage', $imageName);
         $data->image=$imageName;
Prickly Pony

Unggah gambar di Laravel

// Image uploaad laravel
if (!empty($request->files) && $request->hasFile('image')) {
    $input1 = array();
    $upload_path = 'storage/uploads/customers/';
    $old_file = $upload_path . '/' . $input['old_image'];
    if (Storage::exists($old_file)) {
        //delete previous file
        unlink($old_file);
    }
    $file = $request->file('image');
    $file_name = $file->getClientOriginalName();
    $type = $file->getClientOriginalExtension();
    $real_path = $file->getRealPath();
    $size = $file->getSize();
    $size_mbs = ($size / 1024) / 1024;
    $mime_type = $file->getMimeType();

    $file_temp_name = 'profile_' . time() . '.' . $type;
    $old_file = $upload_path . '/' . $file_temp_name;

    $path =  storage_path() . '/app/public/uploads/customers/' . $file_temp_name;
    $img = Image::make($file)->resize(300, 300);
    $img->save($path);
    $input1['image'] = $file_temp_name;
}
Fani385

Unggah gambar di Laravel

  $image= $request->image;
         $imageName=time().'.'.$image->getClientOriginalExtension();
         $request->image->move('imagefolder', $imageName);
         $data->image=$imageName;
Prickly Pony

Unggah gambar di Laravel

<?php

  

use Illuminate\Support\Facades\Route;

  

use App\Http\Controllers\ImageUploadController;

  

  

Route::get('image-upload', [ ImageUploadController::class, 'imageUpload' ])->name('image.upload');

Route::post('image-upload', [ ImageUploadController::class, 'imageUploadPost' ])->name('image.upload.post');
Yucky Yak

Jawaban yang mirip dengan “Unggah gambar di Laravel”

Pertanyaan yang mirip dengan “Unggah gambar di Laravel”

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

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya