, Beautify the custom upload button

Source: Internet
Author: User

The upload button is really ugly. Today I saw someone else'sArticleAfter finding the information, I thought about it. The result is as follows.

The image is as follows:

CodePaste the file as follows:

 @ {Viewbag. Title = "  Indexinput  "  ; Layout = ""  ;} <! Doctype HTML>  "  Content-Type  " Content ="  Text/html; charsets = UTF-8  " > <Title> input file beautification </title> <style> * {Margin:  0  ; Padding:  0  ;}. Btn_addpic {display: block; position: relative; width: 120px; Height: 28px; overflow: hidden; Border: 1px solid # ebebeb; Background: None repeat scroll  0   0 # F3f3f3; color :#  999999  ; Cursor: pointer; text - Align: center;  Float  : Left; margin - Right: 5px;}. btn_addpic span {cursor: pointer; display: block; line - Height: 28px;}. fileprew {cursor: pointer; position: absolute; top:  0  ; Left: 0  ; Width: 120px; Height: 30px; font -Size: 100px; /*  Increase the clickable area of different browsers  */  Opacity:  0 ; /*  Key Points of implementation  */  Filter: alpha (opacity = 0 ); /*  Compatible with IE */  } </Style>  "  @ URL. Action (  " Indexinput "  ,  " Uploader "  )  " Method = "  Post  " Enctype = " Multipart/form-Data  " > <Div style = "  Height: 28px; margin: 100px;  " > <Div Class = "  Btn_addpic  " > <Span> upload images... </Span> <input tabindex = "  3  " Title = "  Supports JPG, JPEG, GIF, and PNG formats. The file size is smaller than 5 MB. " Size = "  3  "  Name = "  PIC  "   Class = "  Fileprew  " Type = "  File  " Onchange = " Document. getelementbyid ('textname'). value = This. Value  " > </Div> <input type = "  Text  " Id = "  Textname  " Style = "  Height: 28px; Border: 1px solid # f1f1f1  " /> </Div> <br/> <input type = "  Submit " /> </Form> </body> 

The CS code is as follows:

 
[Httppost] public actionresult indexinput (Int? Page) {httppostedfilebase saaa = request. files ["upfile"]; httppostedfilebase basefile = request. files [0]; string qqfile = path. getfilename (basefile. filename); stream = basefile. inputstream; using (VAR fliestream = new filestream (httpcontext. server. mappath (@ "\ imagenew \") + qqfile, filemode. create) {stream. copyto (fliestream);} return content ("uploaded successfully! ");}

 

 

 

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.