Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script type="text/javascript">
- $(function() {
- $("#uploadFile").click(function(e) {
- // User clicks form input field and default click action is prevented
- $("#fileUploadField").click();
- e.preventDefault();
- // Once a user clicks they will fire the form action
- $("#fileUploadField").change(function() {
- // iframe HTML
- var iframe = $('<iframe name="postiframe" id="postiframe" target="postiframe" style="display: none;" /></iframe>');
- // Append said iframe
- $("body").append(iframe);
- // Let's submit the form to process on the backend
- var form = $('#UploadForm');
- form.attr("action", "./includes/objects/profile_bg_upload.php");
- form.attr("method", "post");
- form.attr("enctype", "multipart/form-data");
- form.attr("encoding", "multipart/form-data");
- form.attr("target", "postiframe");
- form.attr("hidden", $("input[name=userID]").val());
- form.attr("file", $(this).val());
- form.submit();
- // Load new bg image on the fly
- $("#postiframe").load(function () {
- iframeContents = $("#postiframe")[0].contentWindow.document.body.innerHTML;
- $("#tempBox").html(iframeContents);
- });
- return false;
- });
- $("#UploadForm").submit(function(){
- location.reload()
- });
- });
- });
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement