如何在javascript中编辑FileList对象? [英] How can I edit the FileList object in javascript?

查看:320
本文介绍了如何在javascript中编辑FileList对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在编写一个处理图像并在上传之前显示预览的程序,该预览包括删除选中的一些项目的选项。我已经查看了它,并且我已经能够阅读与此问题相关的帖子不可能,最可行的选择是将所选文件推送到数组中,因为我修改了哪些项目可以从组中删除。我的问题在于我将如何上传剩余的文件,因为文件元素中的项目保持不变....



我一直在学习我自己和我的知识非常有限,我应该如何处理这个问题所以请大家分享你如何解决这个问题。感谢您的时间,我真的很感激。



这里有点我的意思和相当总结:



I'm currently coding a program that handles images and show a preview before upload them, that preview includes the option of deleting some items of the bunch selected. I've look over it and as far as I've been able to read in posts related to this question is "not possible" and the most viable option was to push the selected files in an array as I did to modify which items could be deleted from the group. My problem lies in how I'm going to upload the remaining files since the items in the file element stays immutable....

I've been learning to by my own and my knowledge is pretty limited in how should I approach this issue so please guys feel free to share how you'd solve this. Thanks for your time as well, I really appreciate it.

here it's kind of what I meant and pretty summed up:

<input type='file' id='files' multiple/>

function handlefiles(){
// I'm looping through the files and passing them in an array so I be able to edit it
// say the user selects 8 files then deletes 3 of them... I need to put the 5 remaining files in the $("files").val(); push the array in there or whatever the hell works better to achieve what I want
// now say the 5 remaining files are the ones the user wants to upload, the $("files").val() stays in the previous 8, that's my problem.


}

$("#pics").on('change', function(){
        readURL(); // I'm reading the files as a data URL.
    },handlefiles);



我希望我已经解释过自己,请原谅柏林的英语和问候: )


I hope I had explained myself, forgive the broken English and greetings from Berlin :)

推荐答案

(files)。val();在那里推送数组或者什么地狱更好地实现我想要的东西
//现在说剩下的5个文件是用户想要上传的文件,
("files").val(); push the array in there or whatever the hell works better to achieve what I want // now say the 5 remaining files are the ones the user wants to upload, the


( files)。val()保持在前8,这是我的问题。


}
("files").val() stays in the previous 8, that's my problem. }


(#pics)。on('change',function(){
readURL(); / /我正在将这些文件作为数据URL阅读。
},handlefiles);
("#pics").on('change', function(){ readURL(); // I'm reading the files as a data URL. },handlefiles);



我希望我已经解释过自己,请原谅我的英语和问候来自柏林:)


I hope I had explained myself, forgive the broken English and greetings from Berlin :)


这篇关于如何在javascript中编辑FileList对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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