File upload with thumbnail image

Source: Internet
Author: User

Lead Ajaxfileupload.js Plug-in

<style>
File setting Style: Change to transparent, then let DD set the style to replace him;
If you need to show small hands when hovering, set the font-size to 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>
<Divclass= "Uploadimg">    <DLclass= "Left">      <DT><imgwidth= "the"Height= "The "ID= "Imghead"Data-bind= "attr: {src:saleInfoInput.SealPath}"src= "~/content/images/_register/uploadimg.png" /></DT>      <DD>Click Upload<inputDisabled Class= "Prove"value= "Click to upload"ID= "File1"name= "File1"type= "File"Accept= "Image/png,image/gif,image/jpeg,image/x-ms-bmp"onchange= "Ajaxfileupload (' file1 ', ' hiddensrc ', ' Imghead ')" /></DD>    </DL>    <spanclass= "Uploadimg_list Left">Support for. jpg. jpeg. bmp. gif. png format photo proposal not exceeding 3M</span></Div>

<script>functionajaxfileupload (Fileelementid, HIDDENSRC, Imghead) {$.ajaxfileupload ( {URL:'/uploadfile/upload ',//server-side request address for file uploadsSecureuri:false,//whether a security protocol is required, generally set to falseFileelementid:fileelementid,//ID of the file upload domainDataType: ' Text ',//The return value type is generally set to JSONSuccessfunction(data, status)//Server Success Response handler function                        {                            vararr = Data.split (' {')); vars = Arr[1].split (' < ')); varJSON = "{" + s[0]; varSource = eval (' (' + JSON + ') '); if(source. Success) {varPICTIURESRC =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)//Server Response Failure handler function{alert (e); }                    }                )                return false; }        </script>

Effect

Click Upload

File upload with thumbnail image

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.