更改上传文件的样式<input type="file>

很多人肯定都遇到过关于那个样式只有个浏览按钮的那个上传控件了吧,我也不喜欢啊,因为项目不允许它长那难看,好吧,我采用Js把它巧妙的隐藏伪装了一下,变成了下面的样式,你看还可以不,嘻嘻


浏览就变成了从目录中选择,大家看到的那个文本框其实也不是原有的那个了呢生气,请看代码吧

这是那个表单


<div class="si_form">
    <dl>
      <dt style="margin-bottom:10px;">客户端设置</dt>
      <form action="upload" method="post"  enctype="MULTIPART/FORM-DATA" >
	      <table width="100%" border="0" cellspacing="0" cellpadding="0" class="si_app">
	  <tr>
            <td width="9%"><img src="../static/images/u59.png" width="44" height="40" /></td>
            <td width="16%" align="center">Windows版</td>
            <td><div class="app_bor" id="div_Test">ghfgjfhjf</div></td>
            <td align="left"><div class="file-box">
            <input type='button' class="app_btn" value='从目录中选择' />
   		    <input type="file" name="windows" class="app_file" id="fileField" size="28" οnchange="showText(this)" />
           </div> </td>
            
          </tr>
	  <tr>
	    <td><img src="../static/images/u63.png" width="44" height="47" /></td>
	    <td align="center">Android</td>
	    <td><div class="app_bor" id="div_Test1">ghfgjfhjf</div></td>
	     <td align="left"><div class="file-box">
            <input type='button' class="app_btn" value='从目录中选择' />
   		    <input type="file" name="Android" class="app_file" id="fileField1" size="28" οnchange="showText1(this)" />
           </div> </td>
	  </tr>
	  <tr>
	    <td><img src="../static/images/u61.png" width="48" height="47" /></td>
	    <td align="center">Mac版</td>
	   <td><div class="app_bor" id="div_Test2">ghfgjfhjf</div></td>
	     <td align="left"><div class="file-box">
            <input type='button' class="app_btn" value='从目录中选择' />
   		    <input type="file" name="Mac" class="app_file" id="fileField2" size="28" οnchange="showText2(this)" />
           </div> </td>
	  </tr>
	  
	</table>
	
    </dl>
   <div class="form_but"><input type="submit" value="保存设置"/></div>
   </form>
  </div>
下面是JS


<SCRIPT LANGUAGE="JavaScript">
<!--
function reAsk(sStr)
{
    return confirm(sStr);
}
function getFileName(o)
{
    var pos=o.value.lastIndexOf("\\");
    return o.value.substring(pos+1);//文件名
    
}
function GetFileExt(o)
{
    return o.value.replace(/.+\./,"");
}
function showText(o){
	document.getElementById("div_Test").innerHTML=o.value.substring(o.value.lastIndexOf("\\")+1);
	
}
function showText1(o){
	document.getElementById("div_Test1").innerHTML=o.value.substring(o.value.lastIndexOf("\\")+1);
	
}
function showText2(o){
	document.getElementById("div_Test2").innerHTML=o.value.substring(o.value.lastIndexOf("\\")+1);
	
}

function openBrowse(){ 
	var ie=navigator.appName=="Microsoft Internet Explorer" ? true : false; 
	if(ie){ 
	document.getElementById("file").click(); 
	document.getElementById("filename").value=document.getElementById("file").value;
	}else{
	var a=document.createEvent("MouseEvents");//FF的处理 
	a.initEvent("click", true, true);  
	document.getElementById("file").dispatchEvent(a); 
	} 
} 
//-->
</SCRIPT>

好吧,就这样了,还有Css设置,大家自己弄弄吧 奋斗

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
<td contenteditable="true" ><input type="text" oninput="filterTable(1)" placeholder="aoiStep" ></td> <td contenteditable="true" ><input type="text" oninput="filterTable(2)" placeholder="defectType" ></td> <td contenteditable="true" ><input type="text" oninput="filterTable(3)" placeholder="layerCode" ></td> <td contenteditable="true" ><input type="text" oninput="filterTable(4)" placeholder="type"></td> <td contenteditable="true" ><input type="text" oninput="filterTable(5)" placeholder="dpet" ></td> <td contenteditable="true"><input type="text" oninput="filterTable(6)" placeholder="subcode" ></td> <td contenteditable="true" ><input type="text" placeholder="codeDescription" ></td> <td contenteditable="true" >image1</td> <td contenteditable="true" >image2</td> <td contenteditable="true">image3</td> <td contenteditable="true" >image4</td> <td contenteditable="true" >image5</td> <td contenteditable="true" ><input type="text" placeholder="determination_rule"></td> </tr> </thead> <tbody> <tr> <td contenteditable="true" onclick="selectCell(this)">ACT</td> <td contenteditable="true" onclick="selectCell(this)">Particle</td> <td contenteditable="true" onclick="selectCell(this)">ACT</td> <td contenteditable="true" onclick="selectCell(this)">Particle</td> <td contenteditable="true" onclick="selectCell(this)">ACT</td> <td contenteditable="true" onclick="selectCell(this)">Particle</td> <td contenteditable="true" onclick="selectCell(this)">ACT</td> <td> <input type="file" onchange="previewImage(this);selectCell(this)" onclick="showPopup(this.src)" style="width: 100px; height: auto;"> <td> <input type="file" onchange="previewImage(this);selectCell(this)" onclick="showPopup(this.src)" style="width: 100px; height: auto;"> </td> <td> <input type="file" onchange="previewImage(this);selectCell(this)" onclick="showPopup(this.src)" style="width: 100px; height: auto;"> </td> <td> <input type="file" onchange="previewImage(this);selectCell(this)" onclick="showPopup(this.src)" style="width: 100px; height: auto;"> </td> <td> <input type="file" onchange="previewImage(this);selectCell(this)" onclick="showPopup(this.src)" style="width: 100px; height: auto;"> </td> <td contenteditable="true" onclick="selectCell(this)">Particle</td> 这我的表头,以及表格填充行,我现在需要在保持我现有的功能情况下需要对表格进行修为以下格式,确保数据能偶提交保存到数据库内,并且能将图片行图片保存在电脑本地,后将图片路径保存在数据库内<form action="upload.php" method="POST" enctype="multipart/form-data"> <!-- 表单内容 --> <input type="file" name="image1"> <!-- 其他字段 --> <button type="submit">提交</button> </form>
07-23

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值