
Untitled
By: a guest on
Jun 30th, 2012 | syntax:
None | size: 1.82 KB | hits: 18 | expires: Never
Upload images with jQuery modal dialog sample
<div id="UploadDrivers">
<a href="#" onclick="$('#UploadForm').toggle();return false;" title="Upload New Image">
<img src="/upload.gif" title="Upload New Image" />Upload New Image</a>
<div id="UploadForm" style="display:none;text-align:right;">
<form method="post" enctype="multipart/form-data" style="display:inline;"
action="/uploadLogic.aspx" target="FileUpload"
onsubmit="$('#UploadDrivers').hide(); $('#UploadStatus').show();">
<input type="hidden" name="CALLBACK" value="uploadCallback" />
<input type="file" name="FILE_NAME" />
<input type="submit" value="Upload Image"
onclick="return $('input[name=FILE_NAME]', '#UploadForm').val() != '';"/>
</form>
</div>
<iframe id="FileUpload" name="FileUpload" src="javascript:false;" style="width:1px;height:1px;border:none;"></iframe>
</div>
<div style="text-align:center;display:none;" id="UploadStatus">
Uploading file.... <img src="busy.gif" title="Uploading..." />
</div>
</div>
\Whatever logic you need for your situation to upload a file goes here
script language="javascript" type="text/javascript">
function init(){
var bError = ; //boolean from the upload
var fileGuid = ""; //guid of file on server
var msg = ""; //message to display on callback
var fileName = "" //for friendly display of original name
if(top.) {
top.(bError, guid, filename, msg)
//callback function passed to this page to allow it to be more 'universal'
}
}
/script>
function uploadCallback(error, guid, filename, message) {
if(error) { alert("There was an error uploading the file:rnrn" + message); return; }
$("#UploadDrivers").append(");
//do whatever else
}