katy02's avatar

Update blob image

Hello, I need to upload blob file to database for user registration, but I can't.

This is my code:

User.php protected $fillable = [ 'name', 'email', 'password', 'img' ];

Migration: public function up() { Schema::create('users', function (Blueprint $table) { $table->id(); $table->string('name'); $table->string('email')->unique(); $table->timestamp('email_verified_at')->nullable(); $table->string('password'); $table->binary('img'); $table->rememberToken(); $table->timestamps(); }); }

RegistrerController.php

protected function validator(array $data) { return Validator::make($data, [ 'name' => ['required', 'string', 'max:255'], 'email' => ['required', 'string', 'email', 'max:255', 'unique:users'], 'password' => ['required', 'string', 'min:8', 'confirmed'], 'img' => 'required' ]); }

protected function create(array $data)
{
    return User::create([
        'name' => $data['name'],
        'email' => $data['email'],
        'password' => Hash::make($data['password']),
        'img' => $data['img']
    ]);
}
0 likes
3 replies
katy02's avatar

Doesn't upload the .jpg file correctly to the database. "Something" is uploaded but not the .jpg file :(

If I upload the file directly from phpmyadmin, I can display it with this: img src="data:image/png;base64,{{ chunk_split(base64_encode(Auth::user()->img)) }}"

katy02's avatar

Form:

form class="w-full space-y-6" method="POST" action="{{ route('register') }}" enctype="multipart/form-data"

Please or to participate in this conversation.