【发布时间】:2012-03-02 01:08:44
【问题描述】:
我正在尝试 Dart,但我不知道如何将图像从用户发送到服务器。我有我的输入标签,我可以在 DART 代码中找到它,但我似乎无法从中读取。我正在尝试类似:
InputElement ie = document.query('#myinputelement');
ie.on.change.add((event){<br/>
InputElement iee = document.query('#myinputelement');<br/>
FileList mfl = iee.files;<br/>
File myFile = mlf.item(0);<br/>
FileReader fr = new FileReader();
fr.readAsBinaryString(myFile);
String result = fr.result; //this is always empty
});
html 包含:
<input type="file" id="myinputelement">
我真的希望你不能帮助我,我有点卡住了。我可能只是想念如何为文件阅读器进行加载,或者我做错了。
【问题讨论】:
-
您是否通过
file://协议在Chrome 中加载您的页面?如果是这样,您可能需要启用一些标志 stackoverflow.com/a/7691772/180740 - 或上传文件以通过 HTTP 访问它们。
标签: file-upload dart