2014-02-13 24 views

回答

1

使用此代碼並檢查您的網址顯示圖像。在我的情況下,我使用「/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 }); 
     }); 
    }); 
+0

只記得發送正確的json格式的響應https://github.com/blueimp/jQuery-File-Upload/wiki/JSON-Response和所有的人都沒問題 – GoAntonio

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 
      ?> 

與此默認情況下它會加載下載的模板與文件。

相關問題