且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用< input type =" file"> ;?阅读本地文件

更新时间:2022-12-08 13:11:45

这是新的 File API 从W3C(Mozilla有很多关系)。我已经做了几个File API示例在其他***问题的答案可能是有用的:

It's the new File API from the W3C (which Mozilla had a lot to do with). I've done a couple of File API examples in answers to other *** questions that may be useful:

  • HTML5 File API read as text and binary
  • Get Image dimensions using Javascript during file upload
  • How to know the size of the image to be uploaded with javascript?

第二个,特别是显示将局部图像文件加载到 img 元素中,您可以随时使用 canvas

That second one, in particular, shows loading a local image file into an img element, which you could readily use with a canvas.

如果您想要拖放方面,还可以查看HTML5 拖放东西;相关文章: Google转换为HTML5的Gmail新的拖放附件

If you want the drag-and-drop aspect, you might also check out the HTML5 Drag and Drop stuff; related article: Google Turns to HTML5 for Gmail’s New Drag-and-Drop Attachments.