使用查询设置输入类型文件,插入另存为base64的图像 [英] Setting a input type file with query, inserting image saved as base64

查看:111
本文介绍了使用查询设置输入类型文件,插入另存为base64的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Base64图像字符串,我需要设置输入类型文件字段的值,我无法控制服务器端或站点,因此必须这样做.

I have a Base64 image string, i need to set the value of an input type file field, i have no control of the server side, or of the site, so it has to be done like this.

这可能吗?

针对img上传的FB API请求/响应

响应是一个非常长的jS字符串,它设置了一些值,它的非常非常长,由于对SO的字符限制而无法发布.

The response is a very long jS string setting some values, its very very very long, cannot post due to char restriction on SO.

这似乎是将图像添加到帖子中的方式:

This seems to be how the image is addeded to a post:

<input type="file" class="_n _5f0v" title="Vælg en fil at overføre" multiple="1" name="composer_unpublished_photo[]" aria-label="Føj billeder til dit opslag" id="js_h">

这是在发布包含图像的帖子时发生的情况,该帖子似乎仅在我发布的上一个请求中引用已预先上传的图像.

This is what happens when a post is posted, containing an image, the post only seems to reference the image, that has been pre-uploaded, on the prev request i posted.

推荐答案

需要设置输入类型文件字段的值,我无法控制 服务器端或站点,因此必须这样做.

need to set the value of an input type file field, i have no control of the server side, or of the site, so it has to be done like this.

这可能吗?

否,无法设置" FileList 对象或input元素的File对象

No, it is not possible to "set" the FileList object , or File object of an input element

此类型的对象由HTML的files属性返回 <input>元素;这使您可以访问使用以下选项选择的文件列表 <input type="file">元素.

An object of this type is returned by the files property of the HTML <input> element; this lets you access the list of files selected with the <input type="file"> element.

var file = document.getElementById('fileItem').files [0];

var file = document.getElementById('fileItem').files[0];

方法概述

File item(index);

属性

属性类型说明

length integer只读值,指示列表中的文件数.

length integer A read-only value indicating the number of files in the list.

这篇关于使用查询设置输入类型文件,插入另存为base64的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆