开发者

How to save an image to database using SQLite and PHP?

开发者 https://www.devze.com 2023-03-11 20:34 出处:网络
I want to save an image to the database using SQLite. I send开发者_如何学编程 the image via <input type=\'file\'> in HTML, get the file in the $_FILES var in PHP, and after this, what I should d

I want to save an image to the database using SQLite. I send开发者_如何学编程 the image via <input type='file'> in HTML, get the file in the $_FILES var in PHP, and after this, what I should do?

I created a BLOB field in the database. Currently I'm using SQLite 2.1, because that is the limitation of my homework.

Should I convert an image to binary to store in a database or do something else?


you can do $image = file_get_contents( $_FILES['file']['tmp_name'] );

And then upload it into your blob column (of course it needs to be escaped before, PDO)

0

精彩评论

暂无评论...
验证码 换一张
取 消