Browser Upload component text box to limit the resolution of a method

Source: Internet
Author: User
Tags file size
Solution | browser | upload | text box "problem": the browser Upload component consists of a text input box + a button that pops the selection file box, (pictured):

"Train of Thought":

Recently in the page to find a flaw is difficult to solve: I want to achieve this effect, users can only click to browse the selected file, but not to the selected file path or file name changes (otherwise the user directly arbitrary input or modify the string can upload, but this upload is empty meaningless files, so to do a qualification) , that is, the text input box should be similar to the disabled effect, but the upload component <input type= "File" > if the set disabled can not be uploaded, so think about it or through a workaround to achieve this effect. The final idea is to do a separate text input box set disabled to do the limit, and then set the transparency of the upload component to zero, in IE and FF test has passed!

"Code":

<title>::Test::upload::</title>
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<meta name= "Author" content= "Niko" >
<style type= "Text/css" >
body,td{font-size:12px;}
</style>
<body>
<form method= "POST" action= "enctype=" Multipart/form-data ">
<table width= "100%" border= "0" cellpadding= "0" cellspacing= "0" >
<tr>
&LT;TD height= "450" ></td>
</tr>
<tr>
<td>
<table border= "0" cellpadding= "0" cellspacing= "0" align= "left" >
<tr align= "left" height= ">"
&LT;TD width= > select File:</td>
<td>
<input id= "Txt_file" type= "text" style= "Width:220px;height:20px;background-color: #ffffff; border-top: #7F9DB9 1px Solid;border-left: #7F9DB9 1px solid;border-bottom: #7F9DB9 1px solid;border-right: #7F9DB9 0px solid; "disabled>
</td>
&LT;TD width= "align=" left "style=" Background:url (uploadfile/2005-7/2005728174625830.gif) no-repeat-50px 0px! Important;background:url (uploadfile/2005-7/2005728174625830.gif) no-repeat-50px 1px; " >
<input name= "Upload" id= "up_file" "type=" File "style="-moz-opacity:0;filter:alpha (opacity=0); margin-left:-36px; ">
</td>
</tr>
<tr>
&LT;TD colspan= "3" height= "5" ></td>
</tr>
<tr>
<td> File Description:</td>
&LT;TD colspan= "2" ><input id= "Info_file" type= "text" style= "Width:342px;border: #7F9DB9 1px solid;" ></td>
</tr>
<tr>
&LT;TD colspan= "3" height= "5" ></td>
</tr>
<tr>
<td><input type= "Submit" style= "WIDTH:58PX;" value= "Upload" ></td>
&LT;TD colspan= "2" > Tip: Upload file size can not exceed 10.0 mb</td>
</tr>
<table>
</td>
</tr>
</table>
</form>
</body>

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.