我有一個'上傳'jquery對話框,它顯示一個html上傳表單。我無法確定將表單提交到哪裏,因此我可以檢查代碼是否有效。 此外,在編輯頁面的過程中圖像正在上傳,所以非常重要的是頁面不會重新加載,並且更改不會丟失(用戶在添加圖像之前不會保存其編輯)。如何提交上傳並保留對話框中的所有內容,以便頁面不會重新加載,然後我可以創建一個「插入」代碼將上傳的圖像放入頁面中? 謝謝你,我的代碼是:在jQuery對話框中上傳圖像
public static function uploadImage(){
global $wgOut, $wgRequest;
$posted = $wgRequest->wasPosted();
if($posted) {
$wgOut->addHtml(' Maximum upload size: 2M <br />');
}
// form processing message set at the top if(!empty($message)){$wgOut->addHtml('$message'); };
$wgOut->addHtml(' Upload an Image from your computer: <br />');
$wgOut->addHtml('<form action="" enctype="multipart/form-data" method="Post">
<input type="hidden" name="MAX_FILE_SIZE" value="2000000" />
<input type="file" name="file_upload" id="file_upload" />
<br />
<input type="submit" name="upload" value="Upload" />
</form>
');
$wgOut->addHtml(' Maximum upload size: 2M <br />');
$wgOut->addHtml('Permitted file types: png,gif,jpg,jpeg.');
}
的jQuery:
$("#uploadImage")
.dialog({
autoOpen:false,
title: "Upload Image",
height: "auto",
width: 300
});
$("#uploadImage").dialog("open");
};
和
$wgOut->addHTML('<div id="uploadImage" style="display:none">');
$form = self::uploadImage();
$wgOut->addHtml($form);
$wgOut->addHTML('</div>');
我試着出ajaxfileupload,但我不知道在哪裏把ajax代碼。我試圖把它與對話框,但什麼也沒有發生:如果($( 「#上傳」)爲( 「:勾選」)){\t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t $( 「#uploadImage」) \t \t \t \t \t \t \t \t \t。對話框({ \t \t \t \t \t \t \t \t \t的AutoOpen:假的, \t \t \t \t \t \t \t \t \t標題: 「上傳圖片」, \t \t \t \t \t \t \t \t \t高度: 「自動」, \t \t \t \t \t \t \t \t \t寬度:300 \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t .ajaxStart(函數(){ \t \t \t \t \t \t \t \t $(this).show(); }) \t \t \t \t \t \t \t \t .ajaxComplete(函數(){ \t \t \t \t \t \t \t \t $(本).hide(); \t \t \t \t \t \t \t \t}) }) ; – LTech 2012-03-13 10:09:42
我認爲如果在問題中附加新代碼會更好。 – 2012-03-13 10:15:55