【问题标题】:Uploading form in html issue [duplicate]在html问题中上传表单[重复]
【发布时间】:2015-02-15 15:36:53
【问题描述】:

有表单代码在php中上传文件,见代码:

<html>
<body>

<form action="ok.php" method="get">
Name: <input type="ghf" name="str"><br>

<input type="submit">
</form>


</body>
</html> 

查看图片:

但我们在不同的浏览器中打开此表单时显示为在 Firefox 中浏览并在 Chrome 中选择文件(请参阅图片,顶部是 chrome,第二个是 Firefox) 问题是我想更改此选择文件或浏览的名称,这可能吗?如果是,如何?

【问题讨论】:

    标签: javascript php html


    【解决方案1】:

    文件类型字段的外观因浏览器而异。

    chrome 的默认行为不显示文件类型字段的文本框和按钮。

    您可以参考此link 以获得解决方案。

    【讨论】:

      【解决方案2】:

      input[type=file] 是本机浏览器对象,不能在其中更改。

      您可以尝试并做的是创建一个自定义包装器。

      【讨论】:

        【解决方案3】:

        这些是提交按钮的默认按钮样式。

        您可以通过添加以下内容对其进行编辑:

        Value 属性用于定义按钮的名称。

        http://www.w3schools.com/tags/att_input_value.asp

        【讨论】:

          【解决方案4】:

          试试这个

          <!DOCTYPE html>
          <html>
          <body>
          
          <form action="upload.php" method="post" enctype="multipart/form-data">
              Select file to upload:
              <img src="/images/uploadButton.png" id="upfile1" style="cursor:pointer" />
              <input type="file" id="file1"  name="file1" style="display:none" />
              <input type="submit" value="Upload File" name="submit">
          </form>
          <!--Load jQuery from Google Libraries-->
          <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
          <script type="text/javascript">
              //Using jQuery
              $("#upfile1").click(function () {
                  $("#file1").trigger('click');
              });
          </script>
          
          </body>
          </html>
          

          【讨论】:

            猜你喜欢
            • 2013-03-03
            • 2020-09-06
            • 1970-01-01
            • 1970-01-01
            • 2011-12-04
            • 2011-01-31
            • 1970-01-01
            • 2010-09-20
            • 2011-01-21
            相关资源
            最近更新 更多