duanchijie2323 2014-05-30 05:56
浏览 147
已采纳

在图片上传期间删除上传按钮和文件名

Using the given form, I first click on "Choose File", open the file,its name comes next to it and then I click on "Upload" button" to upload the image.What I want to do is click on "Choose File", open the file but the name should not appear next to it and the image should get uploaded without clicking the "Upload button" after this.How can this be achieved?

  1. <div id="image_container" name="image_container">
  2. <img src="../image/ab.jpg" alt="Cover" width="900px" height="500px">
  3. <div class="btn-group" id="cov" name="cov" >
  4. <button class="btn dropdown-toggle" data-toggle="dropdown" id="mybtn" onclick="dropdown()">Action</button>
  5. <ul class="dropdown-menu" id="dropdown-menu" style="display:none">
  6. <!-- dropdown menu links -->
  7. <li><form action="upload.php" method="post" enctype="multipart/form-data" id="MyUploadForm">
  8. <input name="ImageFile" id="imageInput" type="file" />
  9. <label id="fileup" for="imageInput">Upload File</label>
  10. <input type="submit" id="submit-btn" value="Upload" />
  11. <img src="img/loader.gif" id="loading-img" style="display:none;" alt="Please Wait"/>
  12. </form>
  13. <div id="output"></div>
  14. <li><a href="#">Something else here</a></li>
  15. <li class="divider"></li>
  16. <li><a href="#">Another link</a></li>
  17. </ul>
  18. </div>
  19. </div>
  1. $(document).ready(function() {
  2. var options = {
  3. target: '#output', // target element(s) to be updated with server response
  4. beforeSubmit: beforeSubmit, // pre-submit callback
  5. success: afterSuccess, // post-submit callback
  6. resetForm: true // reset the form after successful submit
  7. };
  8. $('#MyUploadForm').submit(function() {
  9. $(this).ajaxSubmit(options);
  10. // always return false to prevent standard browser submit and page navigation
  11. return false;
  12. });
  13. });

展开全部

  • 写回答

5条回答 默认 最新

  • douwan7382 2014-05-30 06:03
    关注

    Check this Demo Fiddle.

    If you are using jQuery,

    1. $('#imageInput').change(function(){
    2. $("#submit-btn").click(); //$('#MyUploadForm').submit();
    3. });

    Or Just,

    <input name="ImageFile" id="imageInput" type="file" onChange="this.submit();" />
    

    To hide the filename, you have to manipulate the css, or hide the whole button and place another button in it.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)
编辑
预览

报告相同问题?

悬赏问题

  • ¥15 编译python程序为pyd文件报错:{"source code string cannot contain null bytes"
  • ¥20 关于#r语言#的问题:广义加行模型拟合曲线后如何求拐点
  • ¥15 fluent设置了自动保存后,会有几个时间点不保存
  • ¥20 激光照射到四象线探测器,通过液晶屏显示X、Y值
  • ¥15 这怎么做,怎么在我的思路下改下我这写的不对
  • ¥50 数据库开发问题求解答
  • ¥15 安装anaconda时报错
  • ¥15 小程序有个导出到插件方式,我是在分包下引入的插件,这个export的路径对吗,我看官方文档上写的是相对路径
  • ¥20 希望有人能帮我完成这个设计( *ˊᵕˋ)
  • ¥100 将Intptr传入SetHdevmode()将Intptr传入后转换为DEVMODE的值与外部代码不一致
手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部