javascript - Copy and paste images from clipboard, blob Error -


i'm trying copy , paste images clipboard, error message in chrome. wrong?

js fiddle

error

uncaught typeerror: failed execute 'readasdataurl' on 'filereader': argument not blob.  

js

 $(function() { $("body").bind("paste", function(ev) {     var $this = $(this);     var original =  ev.originalevent;     var file =  original.clipboarddata.items[0].getasfile();     var reader = new filereader();     reader.onload = function (evt) {         var result = evt.target.result;          var arr = result.split(",");         var data = arr[1]; // raw base64         var contenttype = arr[0].split(";")[0].split(":")[1];          // needs post server route can accept raw base64 content , save file                     $.post("/echo/html/", {             contenttype: contenttype,             data: data         });                                         $this.append("<img src='" + result + "' />");     };      reader.readasdataurl(file);     });         });  

you're problem that, when browser trying load file through clipboard, looking blob type of data.

blob, or b inary l arge ob ject lengthy string object, instead of being file, string.

by trying copy clipboard, has copy of directory of file, @ least how error , how code is, that's looks like, isn't blob file type, chrome isn't set handle actual file.

i don't know for, if trying save files on database, should have image uploaded through form, have them placed in directory unique name, , store location of each image, actual path, on database.

then, can loop through , need do.

if want, post code have project did this, ask if want it.

it work if you're using mysql server tho; code written in php.

blob wiki article


Comments

Popular posts from this blog

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -

python 3.x - Mapping specific letters onto a list of words -