【问题标题】:jQuery file uploadjQuery文件上传
【发布时间】:2016-12-01 23:22:01
【问题描述】:

我正在使用 Jquery 文件上传小部件,http://blueimp.github.com/jQuery-File-Upload/

我设法以我想要的方式将所有图像保存到我的数据库中,但我无法仅查看我想要的图像。在索引页面中,它会查看“文件”文件夹中的所有图像。

我正在制作一个包含多个相册的图片库。

上图显示了我的照片表。我有图像的名称和一个数字 (in_album),告诉我它在哪个相册中。例如,当我访问 www.example.com/gallery.php/album?12 时,我只希望查看那些 in_album = 12 的照片,而不是文件夹中的所有照片。我想我需要使用 JSON 或其他东西来实现这一点,但我不确定。

【问题讨论】:

  • 选择所需文件夹中的所有照片,返回相同的JSON,循环通过JSON获取图像链接。
  • 您需要在服务器端过滤它作为发出数据库请求的 ajax 请求的结果。您可以向我们发送这样的 GET 请求:wwww.example.com/gallery.php/album?in_album=12 并对您的服务器端逻辑进行编码。希望它对你来说不是中文...
  • 哈哈,有点像。我以前从未使用过 ajax..

标签: php jquery ajax json


【解决方案1】:

没用,但很管用:

    <!-- 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++) { %}


        {% if (file.in_album == '12') { %}


        <tr class="template-download fade">
            <td>
                <span class="preview">
                    {% if (file.thumbnailUrl) { %}
                        <a href="{%=file.url%}" title="{%=file.name%}" download="{%=file.name%}" data-gallery><img src="{%=file.thumbnailUrl%}"></a>
                    {% } %}
                </span>
            </td>
            <td>
                <p class="name">
                    {% if (file.url) { %}
                        <a href="{%=file.url%}" title="{%=file.name%}" download="{%=file.name%}" {%=file.thumbnailUrl?'data-gallery':''%}>{%=file.name%}</a>
                    {% } else { %}
                        <span>{%=file.name%}</span>
                    {% } %}
                </p>
                {% if (file.error) { %}
                    <div><span class="label label-danger">Error</span> {%=file.error%}</div>
                {% } %}
            </td>
            <td>
                <span class="size">{%=o.formatFileSize(file.size)%}</span>
            </td>
            <td>
                {% if (file.deleteUrl) { %}
                    <button class="btn btn-danger delete" data-type="{%=file.deleteType%}" data-url="{%=file.deleteUrl%}"{% if (file.deleteWithCredentials) { %} data-xhr-fields='{"withCredentials":true}'{% } %}>
                        <i class="glyphicon glyphicon-trash"></i>
                        <span>Delete</span>
                    </button>
                    <input type="checkbox" name="delete" value="1" class="toggle">
                {% } else { %}
                    <button class="btn btn-warning cancel">
                        <i class="glyphicon glyphicon-ban-circle"></i>
                        <span>Cancel</span>
                    </button>
                {% } %}
            </td>
        </tr>
                    {% } %}


    {% } %}
    </script>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-12-19
    • 2012-01-30
    • 2021-12-15
    • 2021-08-27
    • 2016-03-14
    相关资源
    最近更新 更多