Upload file without attaching it to a POST

The $post_id argument for media_handle_upload is used to set the column post_parent for attachment post.

Posts without any parent have 0 as post parent, not null.

So, use 0 as argument and it will work.

If you read Codex page linked above it states:

… If you don’t want this media attached to a specific post, you can
pass 0

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)