How can I store a file in the database in the same way WordPress and ACF do?

ACF doesn’t store any file in Database, it simply provides meta fields with user friendly interface.

You can however, store them yourself. To store a field, you need to be familiar with PHP a bit. Here’s how saving a meta field happens, by using the add_post_meta() function:

add_post_meta ( $post_id, 'meta_key', 'meta_value', $is_unique );

There are other functions such as update_post_meta() for various usage. If your forms contains a file, you can handle the upload by using the media_handle_sideload().

Let’s say you have a form like this:

<form method="POST" enctype="multipart/form-data">

    <input type="file" name="some-name"/>

</form>

and you want to save the uploaded file as an attachment. I’m ignoring security and checkup ( they can be found in the codex ) and directly going on how to do it.

You can use the mentioned function to handle the uploaded image, and store the uploaded attachment’s ID:

$image_id = media_handle_upload( 'some-name', $post_id );

update_user_meta( $organisation_id, 'company_logo', $image_id  );

Now, you have access to attachment’s ID, which you can use to retrieve any size of the attachment.