大佬如何读取文件上传,搜索了下资料说是要把file交给input
https://juejin.cn/post/6844904016560783374
https://zhuanlan.zhihu.com/p/31401799
`// ==UserScript==
// @name 上传图片到百度识图
// @namespace http://tampermonkey.net/
// @version 0.1
// @descriptiontry to take over the world!
// @author You
// @match https://image.baidu.com/
// ==/UserScript==
(function() {
'use strict';
const button = document.createElement('button');
button.innerText = "点我授权目录";
document.body.firstChild.after(button);
button.addEventListener('click', async function () {
async function getFile() {
// open directory picker
const dirHandle = await window.showDirectoryPicker({mode:"readwrite"});
console.log(dirHandle);
const button2 = document.createElement('button');
button2.innerText = "点我读取目录&写点东西";
document.body.firstChild.after(button2);
button2.addEventListener('click', async function () {
// 读取目录
for await (const item of dirHandle.values()) {
console.log(item)//打开的文件夹只放了一个图片
console.log(1)
$("#stfile").files=item//这里瞎写的,怎么把文件传值给input呢
}
// 写文件
// const fileHandle = await dirHandle.getFileHandle("hello-world.txt", { create: true });
// const writable = await fileHandle.createWritable();
// await writable.write("Hello World!");
// await writable.close();
});
}
getFile();
});
// Your code here...
})();` ozon 发表于 2022-10-27 16:55
大佬如何读取文件上传,搜索了下资料说是要把file交给input
https://juejin.cn/post/68449040165607833 ...
哥哥另外发一个悬赏贴吧 https://bbs.tampermonkey.net.cn/forum-77-1.html 王一之 发表于 2022-10-27 17:16
哥哥另外发一个悬赏贴吧 https://bbs.tampermonkey.net.cn/forum-77-1.html
{:4_93:}收到!
页:
1
[2]