這個問題類似:在頁面加載https://github.com/blueimp/jQuery-File-Upload/issues/1466如何加載文件數據下載在blueimp jQuery的文件刷新頁面模板上傳
每次,我怎麼默認加載下載的模板與文件中的數據?在谷歌似乎沒有答案。
謝謝。
這個問題類似:在頁面加載https://github.com/blueimp/jQuery-File-Upload/issues/1466如何加載文件數據下載在blueimp jQuery的文件刷新頁面模板上傳
每次,我怎麼默認加載下載的模板與文件中的數據?在谷歌似乎沒有答案。
謝謝。
使用此代碼並檢查您的網址顯示圖像。在我的情況下,我使用「/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 });
});
});
我只是用另一種愚蠢的方式做到了。不確定是否真正的解決方案,但它暫時解決我的問題。
我所按以下步驟進行,
例如:
<?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'].'&_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
?>
與此默認情況下它會加載下載的模板與文件。
只記得發送正確的json格式的響應https://github.com/blueimp/jQuery-File-Upload/wiki/JSON-Response和所有的人都沒問題 – GoAntonio