filelist

Html5 学习系列(四)文件操作API

烈酒焚心 提交于 2019-12-21 04:54:26
引言 在之前我们操作本地文件都是使用flash、silverlight或者第三方的activeX插件等技术,由于使用了这些技术后就很难进行跨平台、或者跨浏览器、跨设备等情况下实现统一的表现,从另外一个角度来说就是让我们的web应用依赖了第三方的插件,而不是很独立,不够通用。在HTML5标准中,默认提供了操作文件的API让这一切直接标准化。有了操作文件的API,让我们的Web应用可以很轻松的通过JS来控制文件的读取、写入、文件夹、文件等一系列的操作,让Web应用不再那么蹩脚,而之前Web应用如果不借助第三方插件,那就是个shit!但是最新的标准中大部分浏览器都已经实现了文件的读取API,文件的写入,文件和文件夹的最新的标准刚制定完毕,相信后面随着浏览器的升级这些功能肯定会实现的非常好,接下来我主要给大家介绍文件读取的几个API。 几个重要的JS对象 1):FileList对象 它是File对象的一个集合,在Html4标准中文件上传控件只接受一个文件,而在新标准中,只需要设置multiple,就支持多文件上传,所以从此标签中获取的files属性就是FileList对象实例。demo:<input type="file" multiple="multiple" name="fileDemo" id="fileDemo" /> ;下面是关于FileList对象的API的原型:

文件放过进剪贴板

一曲冷凌霜 提交于 2019-12-19 03:02:32
procedure CopyFilesToClipboard(FileList: string); var DropFiles: PDropFiles; hGlobal: Thandle; iLen: Integer; begin iLen := Length(FileList) * SizeOf(Char) + 2; FileList := FileList + #0#0; hGlobal := GlobalAlloc(GMEM_SHARE or GMEM_MOVEABLE or GMEM_ZEROINIT, SizeOf(TDropFiles) + iLen); if (hGlobal = 0) then raise Exception.Create('Could not allocate memory.'); begin DropFiles := GlobalLock(hGlobal); DropFiles^.pFiles := SizeOf(TDropFiles); DropFiles^.pt.X := 0; DropFiles^.pt.Y := 0; DropFiles^.fNC := False; DropFiles^.fWide := true; Move(FileList[1], (PAnsiChar(DropFiles) + SizeOf(TDropFiles))

STL中的Sort提示 invalid comparator

大城市里の小女人 提交于 2019-12-18 02:19:08
使用Sort进行排序,最后一个参数cmp函数,调用时,出现Invalid comparator错误,cmp函数如下 bool compare(Node* n1, Node* n2) { return n1->f <= n2->f; } 如果两个元素相等,必须返回false。故改成如下代码,可以通过编绎。 bool compare(Node* n1, Node* n2) { return n1->f < n2->f; } 因为_wfindnext在查找文件时,如果有文件“16.txt”和“5.txt”. 找出来的顺序是16.txt 5.txt.而不是期望的5.txt 16.txt bool sortFun(wstring s1, wstring s2) { if(s1.length()<s2.length()) return true; else return s1<s2; } vector<wstring> filelist; std::sort(filelist.begin(), filelist.end(), sortFun) 这版报错:invalid comparator 改为 bool sortFun(wstring s1, wstring s2) { return (s1.length() < s2.length() || (s1.length() <= s2

How do I remove a file from the FileList

半腔热情 提交于 2019-12-16 22:19:10
问题 I'm building a drag-and-drop-to-upload web application using HTML5, and I'm dropping the files onto a div and of course fetching the dataTransfer object, which gives me the FileList. Now I want to remove some of the files, but I don't know how, or if it's even possible. Preferably I'd like to just delete them from the FileList; I've got no use for them. But if that's not possible, should I instead write in checks in code that interacts with the FileList? That seems cumbersome. 回答1: If you

Merging/combining Filelist

限于喜欢 提交于 2019-12-13 02:04:14
问题 I've got two Filelist objects containing multiple files in a same form and I want to merge it. var data1 = $('#one')[0].files; var data2 = $('#two')[0].files; console.log(data1); console.log(data2); var obj = $.merge(data1,data2); console.log(obj); I tried $.merge and $.extend , the result obj seems have all the files, but the length of it is incorrect: FileList {2: File, 3: File, 0: File, 1: File, length: 2} jsFiddle: https://jsfiddle.net/nxtdnhgu/ 回答1: From jquery documentation. The $.merge

Vue报错:TypeError: Cannot create property 'xxx' on string 'xxxx'

风流意气都作罢 提交于 2019-12-12 17:27:31
报错详情: [ Vue warn ] : Error in callback for immediate watcher "fileList" : "TypeError: Cannot create property 'uid' on string 'string_url_1'" ... 报错原因: TypeError: Cannot create property ‘xxx’ on string ‘xxxx’,此类错误是赋值的 类型错误 ,如以上示例错误,在使用ElementUI的upload组件时,把字符串列表赋值给了 fileList ,而 fileList 需求的是对象的列表。 示例错误代码: pictureList = [ 'string_url_1' , 'string_url_2' ] ; this . fileList = pictureList ; 示例正确代码: pictureList = [ 'string_url_1' , 'string_url_2' ] ; this . fileList = pictureList . map ( item => { return { name : item , url : baseUrl + item } } ) ; 来源: CSDN 作者: 达希希 链接: https://blog.csdn.net/weixin

Very Fast FileList Limitations

杀马特。学长 韩版系。学妹 提交于 2019-12-11 17:48:15
问题 I'm using the below code which is using Win32 calls to get a super fast file list of a directory. It is very quick but has a couple of limitations. 1) It doesn't handle very long paths. Any files below the Windows 260 character path limit will not be found. Potential Answer Below 2) This filelist will not enter shortcut folders like the one below. Is there anyway around these limitations while still holding onto the speed of the operation? private static readonly IntPtr INVALID_HANDLE_VALUE =

WinApi ShellExecuteEx - using verb 'copy' on a file list

假装没事ソ 提交于 2019-12-11 02:23:48
问题 is it possible to use ShellExecuteEx to copy or cut a group of files in a given directory ? The Windows function works fine on a single file but I can't find anywhere any tips over the subject (with a file list). I don't expect any alternative method ( such as xcopy) because I need the windows shell function undo/redo after performing shell-item-specific actions. It's not documented at all in the microsoft msdn library. I've tried to fill the 'lpfile' parameter with a list of items such as

JS > FTP > web directory > filelist

元气小坏坏 提交于 2019-12-10 22:02:05
问题 Is it possible to use Javascript to invoke a FTP call to a specified URL and retrieve all files in this webdirectory? ... 回答1: Assuming you are talking about javascript in the browser, then this is not possible without some supporting server side code. You can use javascript to make an ajax call to a server - the server can invoke FTP and retrieve a file list (or even the files) to the server. These can then be downloaded from the server. 回答2: 9 years later things are much easier. Here is a

阿里云服务器 发送邮箱 STMP 25端口 465端口问题 Javamail 25被禁用

佐手、 提交于 2019-12-09 00:04:30
我们传统使用的比较简单的是 STMP 25端口收发邮件 今天发现刚购买的阿里云服务器不能作为客户端通过STMP 25端口发送邮件 开始在网上有说发现是JDK1.8的原因,然后自己也把JDK1.8换到了JDK1.7 还是不行,所以这里排除了JDK的原因。 那么问题来了,是否25端口不能连接适用喃? 然后在终端输入命令行 ,可测试25端口是否可连接。 telnet smtp.163.com 25 返回成功 说明你的服务器 是没有封掉25端口的。上面的图是我自己的电脑,当然能连通。 当换到服务器测试的时候 就会出现一只连接不成功 找了很久的问题,突然在阿里云客服社区发现一个帖子,当中有客服的解释,当然我不是第一个遇到这个问题的人。 那么客服的解释一下就说明的问题:好像是将25端口封掉了 时间是2016年9月底以后新购买的服务器。 那么问题找到了 那就需要将25端口换到465端口 采用SSL协议传输邮件。 好了贴代码时间到: 下面这段代码是采用SSL协议发送邮件,可向多人单人发送邮件 import java.io.File; import java.io.UnsupportedEncodingException; import java.security.Security; import java.util.Date; import java.util.Map; import java