S
S
Sergey Defactov2017-08-28 22:35:39
C++ / C#
Sergey Defactov, 2017-08-28 22:35:39

Remove storage of images in database in base64 format?

Good evening, please help me figure out the problem, now images are saved in base64 format when adding a post, I need to get rid of this because I am transferring the database from another engine
, there is php associated with adding an image to a post

if (!can_post_to_feed($entity_type, $entity_id, $to_user_id)) return json_encode($result);
    //check for images and videos upload
    $imagesFile = input_file('image');
    $imageToUpdate = false;
    if (!$auto_post and $imagesFile and user_has_permission('can-upload-photo-feed')) {
        $images = array();
        $validate = new Uploader(null, 'image', $imagesFile);
        if ($validate->passed()) {
            foreach($imagesFile as $im) {
                $uploader = new Uploader($im);
                $path = get_userid().'/'.date('Y').'/photos/posts/';
                $uploader->setPath($path);
                if ($uploader->passed()) {
                    $image = $uploader->noThumbnails()->resize()->toDB($entity_type.'-posts', $entity_id, $privacy)->result();
                    $images[$uploader->insertedId] = $image;
                } else {
                    $result['status'] = 0;
                    $result['message'] = $uploader->getError();
                    return json_encode($result);
                }
            }
        } else {
            $result['status'] = 0;
            $result['message'] = $validate->getError();
            return json_encode($result);
        }
        if (!empty($images)) {
            if (count($images) == 1) {
                foreach($images as $imgId => $p) {
                    $imageToUpdate = $imgId;
                }
            }
            $images = perfectSerialize($images);
        }
    }

$feed = db()->query("INSERT INTO `feeds` (is_poll,feeling_data,to_user_id,link_details,can_share,user_id,files,tags,entity_id,entity_type,type,type_id,type_data,photos{$music_colum_sql},video,feed_content,privacy,location,time) VALUES(
        '{$poll}','{$feeling}','{$to_user_id}','{$link_details}','{$can_share}','{$userid}','{$files}','{$tagsData}','{$entity_id}','{$entity_type}','{$type}','{$type_id}','{$type_data}','{$images}'{$music_value_sql},'{$video}', '{$content}', '{$privacy}', '{$location}', '{$time}'
    )");
    if ($feed) {
        session_put(md5($type.$type_id), time());
        if (!$auto_post) {
            session_put(md5('feed'), time());
            session_put(md5('timeline'.get_userid()), time());
        }
        $feed_id = db()->insert_id;
        if (!empty($images)) {
            $images = perfectUnserialize($images);
            if (count($images) == 1) {
                foreach($images as $imgId => $p) {
                    db()->query("UPDATE medias SET ref_id='{$feed_id}',ref_name='feed' WHERE id='{$imgId}'");
                }
            }
        }

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
Griboks, 2019-05-06
@Griboks

Check all possible moves. Choose the ones that give you the most points in the fewest moves. This is the optimal strategy by definition.

A
Alexander Aksentiev, 2017-08-28
@Sanasol

What is the question is not clear.
sanasol.ws/2017/04/05/vuejslaravel-quill-editor-ha...
Here is an example of how to extract base64 from text and save to a file.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question