Automatically save drafts, but how to throw the picture (input file) to the backend? Not through the form way

I use the keyup event to automatically save fields to the database

html

<input type="file" id="file" name="cover" accept="image/jpeg, image/png, image/jpg">

ajax

$("body").on("keyup", "-sharpcontent, -sharptitle", function(e){

var content = $(".note-editable").html();
var title = $("-sharptitle").val();
var file = $("-sharpfile").val();

$.ajax({
      type: "POST",
      url: "auto-save",
      data: {
        "content": content,
        "title": title,
        "file": file
      },
      dataType: "text",
      success: function(data){

but there is a problem
there is an input file,
how can I get him to automatically throw files to the backend? (when input on change)
but this is not in form form. Just take the value and drop the backend
I find that adding this doesn"t work at all

enctype: "multipart/form-data",
cache: false,
contentType: false,
processData: false,

if I don"t go through the form, how to get the picture file of input file so that I can move_uploaded_file?

Oct.26,2021

General more ways
file
images using formdata and h5 are returned via the backend path or marked to the front end


automatic saving is not recommended to use keyup, but interval or timeout recursion.
you can upload pictures with formdata


upload files using FormData objects use documents < / P >


wrote an article for reference: front-end picture direct transmission OSS experiment

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1c2711e-3bc01.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1c2711e-3bc01.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?