I have an 'upload' jquery dialog box which displays a html upload form. I can't work out where to put the php form submission so I can check the code has worked. Also the image is being uploaded in the middle of editing a page so it is very important the page doesn't reload and the changes aren't lost (a user won't save his edits before adding the image). How do I submit the upload and keep everything within the dialog box so the page isn't reloaded and then I can make an 'insert' code to put the uploaded image in the page? Thanks, my code is:
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");
};
and
$wgOut->addHTML('<div id="uploadImage" style="display:none">');
$form = self::uploadImage();
$wgOut->addHtml($form);
$wgOut->addHTML('</div>');