Skip to content

Instantly share code, notes, and snippets.

@dharFr
Created July 23, 2011 14:10
Show Gist options
  • Save dharFr/1101469 to your computer and use it in GitHub Desktop.
Save dharFr/1101469 to your computer and use it in GitHub Desktop.
Asynschronous HTML File Upload (fake Ajax)
<script language="javascript" type="text/javascript">
function formUploadCallback (result) {
console.log("Upload OK:", result);
alert('Upload OK');
}
</script>
<form target="upload_target" action="upload.php" enctype="multipart/form-data" method="post">
File: <input name="myfile" type="file" />
<input name="submitBtn" type="submit" value="Submit" />
</form>
<iframe id="upload_target" name="upload_target" src="#" style="width:0;height:0;border:0px solid #fff;"></iframe>
<script language="javascript" type="text/javascript">
window.top.window.formUploadCallback(<?php echo $result; ?>);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment