使用javascript将捕获的图像上传到后台服务器 [英] upload a captured image to server in background using javascript

查看:112
本文介绍了使用javascript将捕获的图像上传到后台服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


dialog.captureFileAsync(Windows.Media.Capture.CameraCaptureUIMode.photo).done(

dialog.captureFileAsync(Windows.Media.Capture.CameraCaptureUIMode.photo).done(

function (file){

function(file) {

if (file){

if(file) {

var uploader =
new Windows.Networking.BackgroundTransfer。 BackgroundUploader();

varuploader = newWindows.Networking.BackgroundTransfer.BackgroundUploader();

upload = uploader.createUpload(uri,file)

upload = uploader.createUpload(uri, file)

此抛出(类型错误事件异常)。新文件是来自$的捕获图像文件句柄b $ b

This throws (Type mismatach exception). new file is capture image file handle from

}

});

任何想法..为什么以及如何做使用后台上传来上传相机图像,以使用JavaScript窗口8传输捕获图像或视频?

Any ideas.. why and what to do to upload a camera image using background upload to transfer a capture image or video using JavaScript windows 8?

推荐答案

captureFileAsync 返回一个StorageFile,

createUpload
需要一个应该有效的IStorageFile。我看到你的"完成"了处理程序具有"函数(文件)"。处理程序,但你传递一个名为newfile的变量到createUpload,你应该传递"文件",而不是"新文件",我没有看到"新文件",在你的代码中声明

captureFileAsync returns a StorageFile, and createUpload requieres an IStorageFile which should work. I see that your "done" handler has a "function(file)" handler but you are passing a variable called newfile to createUpload, you should pass "file", not "newfile", I don't see "newfile" declared in your code.

dialog.captureFileAsync(Windows.Media.Capture.CameraCaptureUIMode.photo).done(

function(file) {

if(file) {

varuploader = newWindows.Networking.BackgroundTransfer.BackgroundUploader();

upload = uploader.createUpload(uri, file);
upload.startAsync().then(complete, error, progress);//use the handlers you see fit

}

});





这篇关于使用javascript将捕获的图像上传到后台服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆