【问题标题】:How to access file name and other attribute from input type is hidden如何从输入类型访问文件名和其他属性被隐藏
【发布时间】:2016-01-29 16:23:30
【问题描述】:

如果我提交隐藏文件,我如何访问<input type="hidden"> 标签的file name 和文件的其他属性。

我的主要工作是使用Node.js 在服务器上拖放文件。如果我得到一个文件,我可以在输入文件标签上设置这个文件。如果我可以在输入文件标签上动态设置这个文件,我会解决这个问题。

【问题讨论】:

  • 我提交了一个隐藏文件你的意思是说type="hidden"type="file"哪个是隐藏的?
  • 检查答案Check this

标签: javascript jquery node.js html


【解决方案1】:

我认为这是通过添加正常的输入文件来完成的

<html><head>
<style>
.inputFile{
opacity:0;
}

.inputFile:before{
content:"Drag and drop file here";
position: absolute;
    top: 0;
    left: 0;
    z-index: -1;
}
</style>
</head>
<body>
<form>
<div style="
    background-image: url(&quot;download.jpg&quot;);
    width: 200px;
    height: 200px;
    position: relative;
">

<input class="inputFile" type="file" style="
    position: absolute;
    top: 95px;
    left: 32px;
    /* z-index: -1; */
    opacity: 0;
">
</div>

</form>


</body></html>

【讨论】:

  • 我有一个文件。如何使用 node.js、Javascript、Ajax 中的拖放在服务器上发送此文件。
  • 如果您想使用 ajax 提交文件,请使用以下库 malsup.com/jquery/form 我之前在文件上传 ajax 中使用它,它工作正常
【解决方案2】:

要在表单提交后从输入类型中获取值,请参考以下示例-

  <form action="successfulbooking.php" method="post">
        <input type="hidden" name="date" value="hidden_value">  
        <input type="submit" value="Submit Form">
    </form>

成功预订.php

<?php
        $date = $_POST['date'];
        // add code here
    ?>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-07-26
    • 2015-04-09
    • 1970-01-01
    • 2011-01-15
    • 2014-04-24
    • 1970-01-01
    • 1970-01-01
    • 2015-05-28
    相关资源
    最近更新 更多