-2
A
回答
0
好吧,我得到的解決方案,我花時間在它上面。所以我的解決方案是在jQuery彈出窗口中使用iframe,並將其集成到一個自制的框架中。
步驟1:jQuery的彈出窗口
<div id="fileuploadbox" title="Add file(s)"></div>
<script>
function fuBox(aFolder,aId)
{
$("#fileuploadbox").dialog({
autoOpen: false,
modal: true,
width: "850px",
});
$('#fileuploadbox').html('');
$('#fileuploadbox').append($('<iframe width=800 height=400 border=0 />').attr('src', 'index.php?module=fileupload&mode=client&folder='+aFolder+'&id='+aId)).dialog('open');
}
</script>
在我的情況,該文件夾位置取決於基礎文件夾和電網行的id。例如,對於文件夾= article和id = 18756,動態上載路徑爲APP_FILE_PATH/article/18756。
步驟2:IFRAME頁
iframe的頁面是一樣的blueimp jQuery的文件的上傳的的index.html。
<form id="fileupload" action="index.php" method="POST" enctype="multipart/form-data">
<input type="hidden" name="module" value="fileupload">
<input type="hidden" name="mode" value="server">
<input type="hidden" name="folder" value="<?php echo $_GET['folder'].'/'.$_GET['id']; ?>/">
我Concat的文件夾,並在標識一個參數,它都發送到服務器頁面。
在底部,就必須發表評論main.js,使你自己的代碼,我做到了:
<script>
$(function() {
'use strict';
// Initialize the jQuery File Upload widget:
$('#fileupload').fileupload({
// Uncomment the following to send cross-domain cookies:
url: '?module=fileupload&mode=server&folder=<?php echo $_GET['folder']."%2f".$_GET['id']; ?>%2f'
});
// 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: $('#fileupload').fileupload('option', 'url'),
dataType: 'json',
context: $('#fileupload')[0]
}).always(function() {
$(this).removeClass('fileupload-processing');
}).done(function (result) {
$(this).fileupload('option', 'done')
.call(this, $.Event('done'), {result: result});
});
});
</script>
這個代碼是基於main.js,我只是改變了網址,並刪除塊github.io。網址在這裏很重要,因爲它用來刪除上傳的文件。
步驟3:服務器頁
$uploadDir = APP_FILE_PATH."/".$_REQUEST['folder'];
$upload_handler = new UploadHandler(array(
"script_url" => "index.php?module=fileupload&mode=server&folder=".$_REQUEST['folder'],
"upload_dir" => $uploadDir,
"download_via_php" => 1,
));
模式參數僅用於不同iframe的頭版或在我的框架服務器請求的請求。
所以這是我的解決方案,它可以用我的框架爲我工作,也許有一個更簡單的解決方案,我不知道。
相關問題
- 1. 通過圖獲取路徑列表
- 2. 從blueimp文件上傳器獲取所有上傳的文件
- 3. django文件上傳到動態路徑
- 4. 動態文件上傳路徑
- 5. jQuery文件上傳返回文件路徑Blueimp(PHP)
- 6. 通過type = file獲取文件路徑
- 7. 文件上傳:獲取絕對路徑
- 8. 使用blueimp上傳文件上傳東西blueimp文件上傳
- 9. 與Django的Ajax的上傳動態路徑上傳文件
- 10. Jquery文件上傳插件:動態更改上傳路徑?
- 11. 動態獲取路徑路徑
- 12. 迷你Ajax文件上傳器動態上傳路徑
- 13. 通過獲取文件路徑排列TreeView?
- 14. 在FineUploader中獲取上傳文件的文件路徑
- 15. PyroCMS獲取上傳文件的真實文件系統路徑
- 16. PHP:從路徑獲取文件作爲上傳的文件
- 17. 如何獲取上傳文件的文件路徑?
- 18. 從文件上傳的位置獲取文件路徑
- 19. 在MVC 3中獲取上傳文件的文件路徑
- 20. 如何獲取文件上傳的文件路徑
- 21. Pyspark:獲取HDFS路徑上的文件/目錄列表
- 22. 文件上傳通過本地文件路徑
- 23. 獲取文件的路徑從自動保存列表框
- 24. 使用文件上傳控件獲取完整文件路徑
- 25. Blueimp文件上傳:上傳前從文件列表中刪除文件
- 26. 在Django中,上傳時如何獲取上傳文件的文件路徑?
- 27. 如何通過jQuery動態設置上傳目的地(blueimp/jQuery的文件上傳)
- 28. Threepenny-gui:通過'文件'輸入獲取文件路徑
- 29. 如何在jsp上傳文件時獲取文件路徑?
- 30. jQuery的blueimp文件上傳不會通過SSL
'也許jQuery沒有得到動態路徑'也許。發佈您的代碼。 –
這與jQuery File Upload的默認index.html完全一樣。對於上傳,我只添加隱藏的輸入。 – Hugh1024