gpt4 book ai didi

javascript - 如何在 blueimp jquery 下载程序中过滤要下载的文件

转载 作者:行者123 更新时间:2023-11-28 02:45:36 25 4
gpt4 key购买 nike

我正在尝试使用 Blueimp jQuery 文件上传文件程序 https://github.com/blueimp/jQuery-File-Upload 。我已经搜索了 wiki 和文档,但找不到如何过滤可供下载的文件的答案。

我正在经过身份验证的“ protected ”区域内使用它。我已成功在所有上传的文件前面加上唯一的 ID(例如 UID-filename.jpg ),我将在经过身份验证的 session 中使用该 ID。所以我所要做的就是仅选择具有正确 UID 的那些。

显示下载表的 jquery 代码是:

<!-- The template to display files available for download -->
<script id="template-download" type="text/x-tmpl">
{% for (var i=0, file; file=o.files[i]; i++) { %}
<!-- <tr class="template-download fade">-->
<tr class="template-download ">
{% if (file.error) { %}
<td></td>
<td class="name"><span>{%=file.name%}</span></td>
<td class="size"><span>{%=o.formatFileSize(file.size)%}</span></td>
<td class="error" colspan="2"><span class="label label-important">{%=locale.fileupload.error%}</span> {%=locale.fileupload.errors[file.error] || file.error%}</td>
{% } else { %}
<td class="preview">{% if (file.thumbnail_url) { %}
<a href="{%=file.url%}" title="{%=file.name%}" rel="gallery" download="{%=file.name%}"><img src="{%=file.thumbnail_url%}"></a>
{% } %}</td>
<td class="name">
<a href="{%=file.url%}" title="{%=file.name%}" rel="{%=file.thumbnail_url&&'gallery'%}" download="{%=file.name%}">{%=file.name%}</a>
</td>
<td class="size"><span>{%=o.formatFileSize(file.size)%}</span></td>
<td colspan="2"></td>
{% } %}
<td class="delete">
<button class="btn btn-danger" data-type="{%=file.delete_type%}" data-url="{%=file.delete_url%}">
<i class="icon-trash icon-white"></i>
<span>{%=locale.fileupload.destroy%}</span>
</button>
<input type="checkbox" name="delete" value="1">
</td>
</tr>

我对 JS/Jquery 不太有经验。我将不胜感激关于下一步该做什么的任何想法。任何人都熟悉过滤这些文件的设置/选项。或者,我假设该文件是我怀疑可以过滤的文件名或路径的数组。在 PHP 中,我可能会使用 glob 函数。有人在 JS 中有这方面的经验吗?

提前谢谢您,

比尔

最佳答案

使用插件http://sunnywalker.github.io/jQuery.FilterTable/它适用于任何 table 并且易于部署。

包含依赖项:

<script src="/path/to/jquery.js"></script>
<script src="/path/to/bindWithDelay.js"></script> <!-- optional -->
<script src="/path/to/jquery.filtertable.js"></script>
<style>
.filter-table .quick { margin-left: 0.5em; font-size: 0.8em; text-decoration: none; }
.fitler-table .quick:hover { text-decoration: underline; }
td.alt { background-color: #ffc; background-color: rgba(255, 255, 0, 0.2); }
</style> <!-- or put the styling in your stylesheet -->

输入代码

<script>
$('table').filterTable(); //if this code appears after your tables; otherwise, include it in your document.ready() code.
</script>

好的!祝你好运!

关于javascript - 如何在 blueimp jquery 下载程序中过滤要下载的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11937462/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com