Я могу загрузить изображение, декодировать его и перенести в папку. Однако когда я пытаюсь открыть изображение, я получаю следующее сообщение:
Код: Выделить всё
The file could not be opened.
It may be damaged or use a file format that Preview doesn't recognise.
Это сокращенный код изображения, загруженный из базы данных:
Код: Выделить всё
data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkz
ODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2Nj ..... mrvQEGtri5gD2AEvEfhbUD//2Q==
Код: Выделить всё
$img = substr($imageCode, 27); // removed first bit of code.
$image = base64_decode($img); // base 64 decode the image
$file = public_path('app/public/images') . uniqid() . '.jpg'; // got directory to store image
file_put_contents($file, $image); //move the file to the stored location
Подробнее здесь: https://stackoverflow.com/questions/793 ... ot-be-open
Мобильная версия