How to upload an attachment from a custom form to database

I have created a custom html form in pages directory.How to submit the attachment fromcustom generated html form to database.
example:

   <input type = "file" name='attachment'>
   </form>```

Ref:

https://github.com/frappe/frappe/blob/develop/frappe/public/js/frappe/form/sidebar.js#L94

https://github.com/frappe/frappe/blob/develop/frappe/public/js/frappe/form/footer/attachments.js