A
A
aial2017-09-11 05:07:01
PHP
aial, 2017-09-11 05:07:01

How can I reduce the number of characters in the result when saving an image via base64 to the database?

An example of encoding an image in base64 encoding:

$file = file_get_contents($_FILES['file']['tmp_name']);
base64_encode(file_get_contents($file));

After encoding, 5000-8000 characters are obtained. How can I reduce the number of characters?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
O
oh, 2017-09-11
well @AnneSmith

What's the point of putting pictures in the database?
you don’t have an audit for seven years ago

S
Stalker_RED, 2017-09-11
@Stalker_RED

Don't base64 encode, store a binary blob. Base64 by itself increases the size by about 30%.
Or generally save pictures to disk, and write only the path to them in the database.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question