1

How do I insert binary data into a column of type BLOB of a SQLite database in Laravel?

1
  • if you're happy with my answer below, you can accept it :) Commented Apr 6, 2015 at 7:40

1 Answer 1

2

If column in your table is BLOB type, e.g. you created it in migration like this:

Schema::table('images', function($table) {
    $table->binary('data');
})

Then you should be able to insert binary data by using regular insert() method:

DB::table('images')->insert([
    'data' => $binaryFile   
]);

Or like this:

DB::table('test')->insert([
    'data' => DB::raw("LOAD_FILE('/path/to/file')")
]);
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you. It tried several try , but eventually was implemented in x'1234567'. sqlite.1065341.n5.nabble.com/Inserting-BLOB-values-td3611.html

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.