Upload and Convert Base64 String to Image In PHP and Laravel



Let’s Build a Multi-Purpose Laravel + Vue Application is out now. In this series, you learn everything you need to know about Building a complete web application with Laravel and Vue js. So, I am so excited that so many of you guys like my content and keep inspiring me to create more videos. My goals is to inspire you to write better code and better applications.

Open Source At Github.

Here are the things you will learn in this series:

* How use Vue Router with Laravel
* How to Install AdminLTE 3
* How to Use Font Awesome 5 on Laravel
* How integrate mailchimp with laravel
* How to use Laravel Socialite
* How to Login Using Social Media
* How to Use API in Laravel
* Api Auth with Laravel Passport
* JWT with Laravel Passport and JavaScript Request
* Vue Custom Events
* Vue form with Laravel
* Relational Database with Laravel
* Axios and Ajax Request
* ACL in Laravel
* Online Users list
* And much more…

Tags:

JWT with Laravel,tutorial,coding,laravel,laravel and vue js tutorial,laravel and vuejs,laravel and vue js project,laravel admin panel,laravel adminlte,laravel admin,vue js tutorial,vue js,axios,laravel application development,learn laravel 5.6,learn laravel framework,laravel crud,laravel crud tutorial,spa,laravel how to,laravel tips,coding tips,admin lte laravel 5.6,adminlte with php,laravel api,laravel passport, hosting, cloud, web hosting

Nguồn: https://svdpch.org/

Xem thêm bài viết khác: https://svdpch.org/cong-nghe/

21 thoughts on “Upload and Convert Base64 String to Image In PHP and Laravel”

  1. will it work?
    $user = auth('api')->user();

    $image = $request->file('photo');
    $slug = Str::slug($request->name);
    if (isset($image))
    {
    // unique name
    $currentDate = Carbon::now()->toDateString();
    $imagename = $slug.'-'.$currentDate.'-'.uniqid().'.'.$image->getClientOriginalExtension();
    // our image folder
    if (!Storage::disk('public')->exists('profile'))
    {
    Storage::disk('public')->makeDirectory('profile');
    }
    // resize image
    $user = Image::make($image)->resize(180,188)->stream();
    Storage::disk('public')->put('profile/'.$imagename,$user);
    } else {
    $imagename = "profile.png";
    }

    Reply
  2. this is much cleaner
    $extension = explode('/', mime_content_type($request->photo))[1];

    $name = time().'.'.$extension;

    Reply

Leave a Comment