是否有可能从客户端上的文件获取信息,而无需上传文件? [英] Is it possible to get info from a file on the client side without uploading the file?

查看:130
本文介绍了是否有可能从客户端上的文件获取信息,而无需上传文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我允许我的用户上传MP3文件,以便我可以读取元数据并提取歌曲标题和歌手名称。



目前我正在上传文件并使用 getId 来读取元数据。当然上传需要很多的资源和带宽。上传MP3文件似乎有点浪费,因为我需要的只是2段信息,我甚至不会对文件本身做任何事情。所以我把它删除之后。

是否有可能在客户端获取这两条信息而不将这个文件复制到我的服务器?$ b $您只能在符合HTML5的浏览器中执行此操作,这些浏览器实现了

FileReader界面(Firefox,Chrome,IE10,Safari 5.1+,不能确定Opera是什么)。

你基本上使用FileReader将文件的内容存入内存,然后手动扫描(在客户端JavaScript中)所需的MP3标签。


I am allowing my users to upload mp3 files just so I can read the metadata and extract the Song Title and Singer Name.

At the moment I am uploading the file and using getId to read the meta data. The upload of course takes a lot of resources and bandwidth. And it seems kind of wasteful to upload the mp3s since all I need are 2 pieces of information and I won't even be doing anything with the file itself. So I delete it afterwards.

Is it possible to get these 2 pieces of information on the client side without copying the file to my server?

解决方案

you can only do this in HTML5 compliant browsers that implemented the FileReader interface (Firefox, Chrome, IE10, Safari 5.1+, not sure about Opera).

You basically use FileReader to get the contents of your file into memory and then manually scan (in client-side javascript) for the MP3 tags you want.

这篇关于是否有可能从客户端上的文件获取信息,而无需上传文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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