angular.js - Angular中如何从一个图片路径读取出byte数组?
伊谢尔伦
伊谢尔伦 2017-05-15 16:52:34
0
1
1127

如题
现在得到一个

file:///var/mobile/Containers/Data/xxxx.jpg

需要加这个路径的图片读取成byte数组并传给服务器,请问应该如何实现?

PS:
尝试下使用$http读取这个文件

$http.get('file:///var/mobile/Containers/Data/xxxx.jpg')
.success(function(response) {
    alert(response);
});

不知道这里读出的response是什么?

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

reply all(1)
大家讲道理

The following method can convert the requested image result into blob. As for how you want to use it afterwards, it’s up to you

$http.get('http://localhost:9000/test.png')
    .success(function(data) {
        var blob = new Blob([data], {
            type: 'image/png'
        });
        console.log(blob);
    });

I only tried the method of serving images on the server. I don’t know if it will work if you load local images. Because of the content-typeimage/png in the response header of the server’s serve image, I don’t know what’s going on when loading local files

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template