Anriëtte Myburgh
Anriëtte Myburgh

Reputation: 13517

Get image size from data string

I have an image sitting in my database, for which I need the file size in bytes.

How can I get the file size of a data string in PHP?

Thanks in advance.

Upvotes: 2

Views: 147

Answers (2)

HarryFink
HarryFink

Reputation: 1010

This will tell you the data size in bytes:

SELECT OCTET_LENGTH(blob_content) FROM table WHERE id=1

Upvotes: 1

Harikrishnan
Harikrishnan

Reputation: 9979

Try this

SELECT key, LENGTH(blob_column) AS size_in_bytes FROM my_table

Upvotes: 2

Related Questions