How do html picture files post to the server without file?

generally upload a file using type=file provided by the browser.
but I would like to ask whether it is possible to upload a file without selecting a picture and then sending a form form.

has uploaded pictures in this way before, and the pictures on the page are in the following format

clipboard.png

so I want to ask if I can take the string in src to request the server directly to replace the previous picture.
Please give me an idea or post the code if possible.

I read that Baidu"s implementation is to return a url address at the back end for the first time, and then deal with it with the url address.

Jun.05,2021

first of all, how did you get that string?
secondly, if you want to upload a local picture, the browser does not allow you to read it directly, but requires you to use the interface it provides. However, one of the interfaces it provides is file


.

FormData find out? blob find out?

it's time to recommend my own article front-end file upload-javascript-ajax

Let me analyze it for you first. It is now generally divided into two situations.
Old-fashioned , icons are submitted with content. The front end does not need to pay attention to what the address is and where it goes, and the back end needs to receive and store the pictures on its own every time.
split , a special image upload service. Pictures can be transferred to the corresponding background, module and CDN for different purposes. The backend does not care about what picture or how the picture is transmitted, only the url of the picture is needed.


Yes. The corresponding value of src in img is the picture encoded by DataURL. For more information about DataURL encoding, you can first learn about Data URLs

. The data included in

DataURL is a picture encoded by Base64 . If you want to upload a picture encoded by Base64 , you need back-end processing. You can perform decoding the uploaded Base64-encoded picture , write to the file, and save the corresponding extension through MIME type in DataURL .


you can construct a form, to post the value of src.

let f=$('form').attr('method','post').attr('src','http://scooterlabs.com/echo');
f.append('input').attr('name','file').attr('value',$('img').attr('src'));
f.submit();

it would be nice for the server to receive and parse.

Menu