converting blob image to file in php

The BLOB is the binary image. You can write that image to your filesystem once it's on your server. So if your image is in the variable $my_blob, you would do something like

file_put_contents('/path/to/new/file_name', $my_blob);

and there you go.

You might want to save the file to a tmp location first, then do some checks on it before you move it to a final location (with PHPs rename() function).

Btw: why not just save the BLOB to DB? That is a legitimate way of handling files these days, that's what the BLOB MySQL data type is for after all.


Try just writing it to a file with an image/[fill-in-the-blank] mimetype. Or maybe imagecreatefromstring will work. (NOT sure about any of these)

Or you can find another way to resize the images.

Tags:

Php