檔案上傳帶縮圖

來源:互聯網
上載者:User

標籤:accept   inpu   border   照片   lis   color   val   erro   license   

提前引 ajaxfileupload.js 外掛程式

<style>
//file設定樣式:變透明,然後讓dd設定樣式代替他;
如果懸浮時需要顯示小手,將font-size設定成0
.uploadImg dl dd{  width:110px;height:31px;line-height:30px;background:#f56d66;border:none;color:#fff;border-radius:3px;margin-top:11px;text-align:center;cursor:pointer;}
.uploadImg .Prove{ position: absolute;bottom:0;left:0; opacity: 0; filter:Alpha(opacity=0); width:110px;height:31px;cursor:pointer;font-size:0 }.uploadImg_list{width:228px;}

</style>
<div class="uploadImg">  <dl class="left">    <dt><img width="112" height="86" id="imghead" data-bind="attr: { src: saleInfoInput.SealPath}" src="~/Content/images/_register/uploadImg.png" /></dt>    <dd>點擊上傳<input disabled class="Prove" value="點擊上傳" id="file1" name="file1 " type="file" accept="image/png,image/gif,image/jpeg,image/x-ms-bmp" onchange="ajaxFileUpload(‘file1‘, ‘hiddenSrc‘, ‘imghead‘)" /></dd>  </dl>  <span class="uploadImg_list left">支援.jpg .jpeg .bmp .gif .png格式照片單張建議不超過3M</span></div>

 <script>            function ajaxFileUpload(fileElementId, hiddenSrc, imghead) {                $.ajaxFileUpload                (                    {                        url: ‘/UploadFile/Upload‘, //用於檔案上傳的伺服器端請求地址                        secureuri: false, //是否需要安全性通訊協定,一般設定為false                        fileElementId: fileElementId, //檔案上傳域的ID                        dataType: ‘text‘, //傳回值類型 一般設定為json                        success: function (data, status)  //伺服器成功響應處理函數                        {                            var arr = data.split(‘{‘);                            var s = arr[1].split(‘<‘);                            var json = "{" + s[0];                            var source = eval(‘(‘ + json + ‘)‘);                            if (source.Success)                            {                                var pictiureSrc = source.Data;                                //$("#"+hiddenSrc+"").val(pictiureSrc);                                $("#" + imghead + "").attr("src", ‘/UploadFile/GetImagefile?fileinfo=‘ + pictiureSrc + ‘&&type=s‘)                                if(fileElementId==""){                                    module.viewModel.saleInfoInput.BusinessLicensePath("");                                }                                                           }                        },                        error: function (data, status, e)//伺服器響應失敗處理函數                        {                            alert(e);                        }                    }                )                return false;            }        </script>

效果

點擊上傳

 

檔案上傳帶縮圖

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.