zoukankan      html  css  js  c++  java
  • H5 移动端相册拍照 录音 录像,然后上传后台

            
                    <input type="file" id="imagesel" accept="image/*" capture="camera"
                    onchange="upload(this)" style="display:none">
                    
                    
                <input type="file" id="videosel" accept="video/*" capture="camcorder"
                    onchange="upload(this)" style="display:none">
                <input type="file" id="audiosel" accept="audio/*"
                    capture="microphone" onchange="upload(this)" style="display:none">
    
    
                <div onclick="add_img()"
                    style="position: relative;32%;height:100%;top:25%;text-align: center;line-height:center">
    
                    <div class="geticonfont">&#xe765;</div>
                    <div class="titlename1">拍照</div>
    
                </div>
                <div onclick="add_video()"
                    style="position: relative;32%;height:100%;top:25%;text-align: center;line-height:center">
    
                    <div class="geticonfont">&#xe66f;</div>
                    <div class="titlename1">录像</div>
    
                </div>
                <div onclick="add_audio()"
                    style="position: relative;26%;height:100%;top:25%;text-align: center;line-height:center">
    
                    <div class="geticonfont">&#xe610;</div>
                    <div class="titlename1">录音</div>
    
                </div>

    阿里小图标引用需自行下载

        function add_img() {
                document.getElementById("imagesel").click();
            
                console.log("调用相机");
            }
            function add_video() {
                document.getElementById("videosel").click();
            
                console.log("调用摄像机");
            }
            function add_audio() {
                document.getElementById("audiosel").click();
                
                console.log("调用录音");
            }

    文件上传:

        //图片上传
            function upload(file) {
              
                var formData = new FormData();
                formData.append("file", file.files[0]);
    
                var u = window.localStorage.getItem("pocurl")
                        + "/materials/pocEvent/upload";
                console.log("U:" + u);
                //  alert(formData);
                // alert(file);
    
                $
                        .ajax({
                            url : u,
                            type : 'POST',
                            data : formData,
                            processData : false,// 告诉jQuery不要去处理发送的数据
                            contentType : false,// 告诉jQuery不要去设置Content-Type请求头
                            beforeSend : function() {
    
                            },
                            complete : function() {
    
                            },
                            success : function(res) {
                                
                              
                            }
                        });
    
            
    
            }

    该文章个别参数没有详细说明,如果不清楚请参考上篇博客,上篇博客参数介绍十分详细:https://www.cnblogs.com/ttqi/p/14034229.html

  • 相关阅读:
    Elasticsearch入门系列(一)
    清楚Chrome缓存
    解决IIS启动站点报错
    Input type="file"上传文件change事件只触发一次解决方案
    本地计算机上的XXX服务启动后停止,某些服务在未由其它服务或程序使用时将自动停止
    SQL Server Datetime类型为NULL不能用ISNULL(datetime,' ')来判断,会导致1900-01-01
    浏览指南
    谁发明的c++
    c++的用处
    不一样的二叉树遍历(小学生都会)
  • 原文地址:https://www.cnblogs.com/ttqi/p/14034271.html
Copyright © 2011-2022 走看看