I have a problem here, I want to save a summary of the news that the user will create, I don't want if the user uploads an image, the tag will not be stored in the summary column, how do I do that?
$content = $request->content;
$dom = new \DomDocument();
$dom->loadHtml($content, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
$images = $dom->getElementsByTagName('img');
foreach($images as $k => $img){
$data = $img->getAttribute('src');
list($type, $data) = explode(';', $data);
list($type, $data) = explode(',', $data);
$data = base64_decode($data);
$image_name= '/upload/'.time().$k.'.png';
$path = public_path() . $image_name;
file_put_contents($path, $data);
$img->removeAttribute('src');
$img->setAttribute('src', $image_name);
}
$description = $dom->saveHTML();
$summernote = new News();
$summernote->title = $request->title;
$summernote->content = $description;
$summernote->summary = I don't know what I'm going to write here
$summernote->save();
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3An0nKB
via IFTTT
Aucun commentaire:
Enregistrer un commentaire