文件上传比较丑,样式调整时会有一个获取文件名,或者包含文件路径的文件名的方法

html代码

    <div class="file-box">
<form id="uploadForm">
<input type="text" id="textfield" class="txt" />
<input type="button" class="btn" value="浏览..." />
<input type="file" name="file" class="file" id="fileField" onchange="document.getElementById('textfield').value=this.files[0].name"/>
<input type="submit" class="btn" value="上传" />
</form>
</div>

CSS样式

.file-box{ position:relative;width:340px;margin:20px;}

.txt{ height:28px;line-height:28px; border:1px solid #cdcdcd; width:180px;}

.btn{width:70px; color:#fff;background-color:#3598dc; border:0 none;height:28px; line-height:16px!important;cursor:pointer;}

.btn:hover{background-color:#63bfff;color:#fff;}

.file{ position:absolute; top:0; right:85px; height:30px;line-height:30px; filter:alpha(opacity:0);opacity: 0;width:254px }

效果图

只获取文件名

document.getElementById('fileField').files[0].name

获取带路径的文件名

document.getElementById('fileField').value

最新文章

  1. 批处理——服务器的web文件备份
  2. OpenGL利用模板测试实现不规则裁剪
  3. 生产uuid
  4. PNG图片压缩工具
  5. Google 开发新的开源系统 Fuchsia
  6. POJ 1741 树上的点分治
  7. jquery插件formValidator的ajaxValidator传参数问题
  8. iOS应用中URL地址如何重定向-b
  9. oracle数据库删除数据Delete语句和Truncate语句的对比
  10. POJ 3267-The Cow Lexicon(DP)
  11. win32 Message(MSG)消息处理
  12. spring boot 错误,求大神帮解决
  13. Cell重用时数据混乱的管理方法
  14. Oracle数据库(三)表操作,连接查询,分页
  15. 关于MySql经典高频查询语句的整理
  16. YARN详解
  17. Git的安装和配置用户名和密码
  18. python 中的 and / or
  19. c# MVC Action 如何知道 发送方给你的 Json 数据的格式内容是什么
  20. CMUSphinx Learn - Basic concepts of speech

热门文章

  1. 将已有项目同步到远程git仓库(github,gitee)及giteee的visual studio插件使用一二
  2. c++构造函数问题,初始化和赋值问题
  3. (一)ByteDance编程题
  4. bashrc 与 profile 环境变量
  5. java 实现导出Excel文件
  6. JavaBean简介和用法
  7. Github常见命令整理
  8. 机器学习--最邻近规则分类KNN算法
  9. JAVA第一个程序hello world
  10. day34 协程