【问题标题】:Select a image to be uploaded from URL with jQuery使用 jQuery 从 URL 中选择要上传的图像
【发布时间】:2022-01-22 17:01:37
【问题描述】:

我只需要 选择的文件作为 URL,所以当我按下诉讼时将是 URL 内容

<form method="POST" action="index.php" enctype="multipart/form-data" >
   <input type="file" name="file" id="file">
   <input type="submit" value="submit"  name="submit">
</form>

【问题讨论】:

  • 问题不清楚。文件输入给出了本地机器上文件的文件路径,而不是远程资源的 URL。此外,出于安全原因,该文件路径被混淆,因此您无法枚举客户端的文件夹结构。如果您能告诉我们您到底想做什么以及为什么要这样做,也许您的问题会得到更好的答复。
  • 我正在将 Forminator 插件用于我的一个具有多步骤表单的项目。我想保存该用户提供的数据,以便他们稍后可以继续并完成输入所有仍为空的字段。我设法将所有内容保存在我的 SQL 中,但是当我从 SQL 加载数据时,文件是我加载时唯一遇到的问题,我无法预先选择完成。

标签: jquery url file-upload


【解决方案1】:

类型文件无法进行预选,您可以使用一些插件,例如http://blueimp.github.io/jQuery-File-Upload/,或者您可以使用类似的东西

*{margin:0;box-sizing:border-box;}
input, textarea{font:14px/1.4 sans-serif;}

.input-group{
  display: table;
  border-collapse: collapse;
  width:100%;
}
.input-group > label,.input-group > div{
  display: table-cell;
  border: 1px solid #ddd;
  vertical-align: middle;  /* needed for Safari */
}
.input-group-icon{
  background:#eee;
  color: #777;
  padding: 0 12px
}
.input-group-area{
  width:100%;
}
.input-group input{
  border: 0;
  display: block;
  width: 100%;
  padding: 8px;
}
<div class="input-group">
  <label class="input-group-icon" for="file">browse...</label>
  <div class="input-group-area"><input type="text" id="preview" placeholder="No file selected..." readonly value="my_drafted_image.png"></div>
       <input type="file" id="file" onchange="document.getElementById('preview').value = this.files.item(0).name" style="display:none">
</div>

【讨论】:

  • 谢谢你帮我清理
猜你喜欢
  • 2012-02-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-10-08
  • 2017-03-12
  • 2014-09-11
相关资源
最近更新 更多