File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed
Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -284,14 +284,24 @@ file.addEventListener(
284284 event .target .files , 0
285285 );
286286 files .forEach (function (item ){
287- files2dataurl (item . function (url){
287+ files2dataurl (item, function (url ){
288288 var image = new Image ();
289289 parent .appendChild (image);
290- Image .src = url;
290+ image .src = url;
291291 });
292292 });
293293 }
294294);
295+ function file2dataurl (file , callback ) {
296+ if (! window .FileReader ) {
297+ throw ' Browser not support File API !' ;
298+ }
299+ var reader = new FileReader ();
300+ reader .readAsDataURL (file);
301+ reader .onload = function (event ) {
302+ callback (event .target .result );
303+ };
304+ }
295305```
296306
297307NOTE:` accept ` 所支持的格式有 ` audio/* ` ` video/* ` ` image/* ` 以及不带` ; ` 的 MINE Type 类型和 ` . ` 开头的文件名后缀的文件。多个文件类型可以使用` , ` 分隔。
You can’t perform that action at this time.
0 commit comments