我有一个'上传'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