how to upload base64 image in codeigniter using postman

preview_player
Показать описание
hi guys in this video we learn how to upload base64 image in codeigniter using postman.
code
//generate unique name
$date = new DateTime();
$startdata = $date-format('YmdHis');
$newName = str_replace('/', '', $startdata) . $userid;

// get base64 image form request
// you just need to replace the content variable with your variable send from the postman
//replace bracket

$image =$this-*input-*post("content");

$image_name= $newName;

//convert base64 to image and save in specific location/dir
file_put_contents(
"application/assets/uploads/".$image_name.".jpg",
base64_decode(
str_replace('data:image/jpeg;base64,', '', $image)
)
);

if you have any issue comment below

share support subscribe
#allroundzone
#allround







Рекомендации по теме
Комментарии
Автор

Thank you so much. It really helped me a lot

muhammadsaqlain
Автор

How to decode base64 from api frontend?

rumpinetijen
join shbcf.ru