简体   繁体   English

发送base64字符串图像以形成输入字段

[英]Send base64 string image to form input field

I have a plugin which crops my image and sends back a base64 data that looks like this: data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQ... 我有一个插件来裁剪我的图像data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQ...回一个如下所示的base64数据: data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQ...

Question is how can I send that data to my file input field? 问题是如何将该数据发送到我的文件输入字段? If I do $("input#file").val(img); 如果我做$("input#file").val(img); where img is my base64 string I get SecurityError: The operation is insecure. 其中img是我的base64字符串我得到SecurityError: The operation is insecure.

you can not set the value of a file input field . 您无法设置文件输入字段的值。 There may be other alternatives such as setting the base 64 value to a hidden input field and then submitting the form. 可能还有其他替代方法,例如将base 64值设置为隐藏的输入字段,然后提交表单。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM