0

类似于这个问题:https ://github.com/blueimp/jQuery-File-Upload/issues/1466

每次页面加载时,我如何默认加载带有文件数据的下载模板?谷歌似乎没有答案。

谢谢。

4

2 回答 2

1

使用此代码并检查您的 url 以获取显示图像。就我而言,我使用的是“/Upload/UploadHandler.ashx”。

您放入 main.js 中的这段代码。

$(function () {
        'use strict';

        // Initialize the jQuery File Upload widget:
        $('#fileupload').fileupload();

        $('#fileupload').fileupload('option', {
            maxFileSize: 500000000,
            resizeMaxWidth: 1920,
            resizeMaxHeight: 1200
        });

        // Enable iframe cross-domain access via redirect option:
        $('#fileupload').fileupload(
            'option',
            'redirect',
            window.location.href.replace(
                /\/[^\/]*$/,
                '/cors/result.html?%s'
            )
        );

        // Load existing files:
        $('#fileupload').addClass('fileupload-processing');
        $.ajax({
            // Uncomment the following to send cross-domain cookies:
            //xhrFields: {withCredentials: true},
            url: "/Upload/UploadHandler.ashx",
            dataType: 'json',
            context: $('#fileupload')[0]
        }).always(function () {
            $(this).removeClass('fileupload-processing');
        }).done(function (result) {
            $(this).fileupload('option', 'done')
                .call(this, $.Event('done'), { result: result });
        });
    });
于 2014-02-13T12:56:13.250 回答
0

我只是用另一种愚蠢的方式做到了。不确定是否是真正的解决方案,但它暂时解决了我的问题。

我所做的如下,

  1. 如果照片数据在表中可用,请检查数据库。
  2. 如果返回 true,我将显示上传模板(从 blueimp 中的默认脚本复制)

例如:

<?php 
                if($imageResults != false){                      
                    //show image
                    while($imageRow=mysqli_fetch_array($imageResults))
                    {
                        echo '<div class="template-download fade in" style="float:left; display:inline-block; margin: 0 10px 10px;">
    <div>
        <span class="preview">

                <a href="/upload/server/php/files/"'.$imageRow['name'].'" title="'.$imageRow['name'].'" download="'.$imageRow['name'].'" data-gallery=""><img src="/upload/server/php/files/thumbnail/'.$imageRow['name'].'"></a>

        </span>
    </div>
    <div>

            <button class="btn btn-danger delete" data-type="POST" data-url="/upload/server/php/?file='.$imageRow['name'].'&amp;_method=DELETE">
                <i class="glyphicon glyphicon-trash"></i>
                <span>Delete</span>
            </button>
            <input type="checkbox" name="delete" value="1" class="toggle">

    </div>
</div>';
                    }
                }
                //else leave blank
            ?>

默认情况下,它将加载带有文件的下载模板。

于 2014-02-17T09:57:09.853 回答