问题描述
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 = 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? 返回一个StorageFile, captureFileAsync returns a StorageFile, andcreateUpload 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. 这篇关于使用javascript将捕获的图像上传到后台服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
new Windows.Networking.BackgroundTransfer。 BackgroundUploader(); 推荐答案
createUpload 需要一个应该有效的IStorageFile。我看到你的"完成"了处理程序具有"函数(文件)"。处理程序,但你传递一个名为newfile的变量到createUpload,你应该传递"文件",而不是"新文件",我没有看到"新文件",在你的代码中声明
。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
}
});