Input file style, document PATH, filename acquisition

Source: Internet
Author: User

http://blog.csdn.net/comikey/article/details/8954479 solution is to put input on the top of the text, make transparent, so in the point of text, the actual click on input, so that the implementation of the file upload. Isn't it simple? Specific code: <style> #uploadImg {font-size:12px; overflow:hidden; Position:absolute} #file {position:absolute; z-index : 100; margin-left:-180px; Font-size:60px;opacity:0;filter:alpha (opacity=0); margin-top:-5px;} </style> <span id= "uploadimg" ><input type= "file" id= "file" size= "1" ><a href= "#" > Upload image </a > </span> so you can change the style to a picture, or a text with a background ... And so on how to change how to change. and also compatible with Ie6/ie7/firefox
1 <Liclass= "F_input"><spanclass= "T">Upload your CV:</span>2    <spanID= "Uploadimg">3       <inputtype= "File"ID= "File"size= "1" >4         <ahref="#">Click to upload your CV</a> 5    </span>6    <PID= "em">File not uploaded</P>7 </Li>
1 . sq_list li.f_input #em{Margin-left:195px;Line-height:32px;Color:#666;font-size:13px;}2 #uploadImg{cursor:Pointer;Overflow:Hidden;position:relative;width:104px;Height:32px;}3 #file{cursor:Pointer;position:Absolute;Z-index: -; Left:0;Top:0;width:104px;Height:32px;Opacity:0;Filter:Alpha (opacity=0);}4 #uploadImg a{cursor:Pointer;background:#0e2d43;position:Absolute;Top:0; Left:0;Display:Block;width:104px;Height:32px;text-align:Center;Line-height:32px;Color: White;font-size:14px;Font-weight:Normal;}

Pass-Through---Full path acquisition of file names

$ (' #file '). Change (function() {    $ (' #em '). Text ($ (' #file '). Val ());});

The file name is passed---get only the file name

1 var file = $ (' #file '),2     aim = $ (' #em '); 3     function (e) {4         // E.currenttarget.files is an array, and if multiple files are supported, you need to traverse 5         var name = E.currenttarget.files[0].name; 6         Aim.text (name); 7     });

Input file style, document PATH, filename acquisition

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.