To achieve the desired functionality, you can implement a file input that remains hidden and is activated by clicking another element on the page.
Once you select a file using the file input, you can add the file to a FormData object and then send it as the post body in an ajax request.
var data = new FormData()
var file = document.getElementById('my-file-element').files[0]
data.set('key', file)
// Proceed with sending the ajax request including the form data.
Check out the FormData documentation
Update: addressing your specific requirements
If you're aiming to capture a "screenshot" of a div, one approach is to convert the div to a canvas and then convert the canvas into a blob. You can subsequently submit this blob utilizing the method described above.