首页 新闻 赞助 找找看

使用h5 plus.uplouad 上传的文件后台控制器如何写,ssm的?

0
悬赏园豆:80 [待解决问题]

var cmr = null // 初始化变量

// 创建plus环境
if (window.plus) {
plusReady();
} else {
document.addEventListener('plusready', plusReady, false);
}

function plusReady() {
cmr = plus.camera.getCamera(); // 初始化摄像头
}

/ 摄像
function videoCapture() {

    var res = cmr.supportedVideoResolutions[0];  // 获取手机支持的视频分辨率,默认获取第一个(这样写的情况下)
    var fmt = cmr.supportedVideoFormats[0];  // 获取手机支持的视频格式,默认获取第一个(这样写的情况下)
    console.log("Resolution: " + res + ", Format: " + fmt);
    $('#xx').append("Resolution: " + cmr.supportedVideoResolutions + ", Format: " + fmt);
    cmr.startVideoCapture(function (path) {
            // 拍摄视频成功
            //  <span>alert</span>( "Capture video success: " + path );
            // 上传方法
            createUpload(path)
        },
        function (error) {
            // 拍摄视频失败,取消录制视频也会触发
            <span>alert</span>( "Capture video failed: " + error.message );
        },
        // 指定参数
        {resolution: res, format: fmt, index: 1}
    );

}

// 拍照
function captureImage() {

    // var cmr = plus.camera.getCamera();
    var res = cmr.supportedImageResolutions[0];  // 获取手机支持的图片分辨率,默认获取第一个(这样写的情况下)
    var fmt = cmr.supportedImageFormats[0];  // 获取手机支持的图片格式,默认获取第一个(这样写的情况下)
    console.log("Resolution: " + res + ", Format: " + fmt);
    cmr.captureImage(function (path) {

// <span>alert</span>( "Capture image success: " + path );
createUpload(path)
},
function (error) {
// <span>alert</span>( "Capture image failed: " + error.message );
},
{resolution: res, format: fmt}
);

}

function createUpload(file) {
// 创建一个上传的任务,upload_url是要上传的服务器地址
var task = plus.uploader.createUpload('http://192.168.43.182:8080/file/Upload', {method: "POST"}, function (t, status) {
// 上传完成
if (status == 200) {
// 上传成功
} else {
// 上传失败
}
});
task.addFile(file, {key: "file"}); // 添加文件
// task.addData( "string_key", "string_value" ); 可以添加需要上传的json数据
task.start(); // 开始上传
}

问题补充:

控制器不知道该怎么写去获取这些文件

陶非凡的主页 陶非凡 | 初学一级 | 园豆:122
提问于:2019-02-26 15:31
< >
分享
所有回答(1)
0

var cmr = null // 初始化变量 // 创建plus环境 if (window.plus) { plusReady(); } else { document.addEventListener('plusready', plusReady, false); } function plusReady() { cmr = plus.camera.getCamera(); // 初始化摄像头 } / 摄像 function videoCapture() { var res = cmr.supportedVideoResolutions[0]; // 获取手机支持的视频分辨率,默认获取第一个(这样写的情况下) var fmt = cmr.supportedVideoFormats[0]; // 获取手机支持的视频格式,默认获取第一个(这样写的情况下) console.log("Resolution: " + res + ", Format: " + fmt); $('#xx').append("Resolution: " + cmr.supportedVideoResolutions + ", Format: " + fmt); cmr.startVideoCapture(function (path) { // 拍摄视频成功 // <span>alert</span>( "Capture video success: " + path ); // 上传方法 createUpload(path) }, function (error) { // 拍摄视频失败,取消录制视频也会触发 <span>alert</span>( "Capture video failed: " + error.message ); }, // 指定参数 {resolution: res, format: fmt, index: 1} ); } // 拍照 function captureImage() { // var cmr = plus.camera.getCamera(); var res = cmr.supportedImageResolutions[0]; // 获取手机支持的图片分辨率,默认获取第一个(这样写的情况下) var fmt = cmr.supportedImageFormats[0]; // 获取手机支持的图片格式,默认获取第一个(这样写的情况下) console.log("Resolution: " + res + ", Format: " + fmt); cmr.captureImage(function (path) { // <span>alert</span>( "Capture image success: " + path ); createUpload(path) }, function (error) { // <span>alert</span>( "Capture image failed: " + error.message ); }, {resolution: res, format: fmt} ); } function createUpload(file) { // 创建一个上传的任务,upload_url是要上传的服务器地址 var task = plus.uploader.createUpload('http://192.168.43.182:8080/file/Upload', {method: "POST"}, function (t, status) { // 上传完成 if (status == 200) { // 上传成功 } else { // 上传失败 } }); task.addFile(file, {key: "file"}); // 添加文件 // task.addData( "string_key", "string_value" ); 可以添加需要上传的json数据 task.start(); // 开始上传 }

黑蛮 | 园豆:206 (菜鸟二级) | 2021-10-10 11:09
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册