anderson_catchme Posted September 6, 2014 Share Posted September 6, 2014 (edited) $(document).ready(function() { var uploadObj = $("#fileuploader").uploadFile({ url:"upload.php", fileName:"myfile", }); }); I'm trying to call UploadObj.uploadFile(); on a click event. Removing the "var" to make the scope global works sort of but also throws errors. Not sure what to do. Help appreciated. Edited September 6, 2014 by anderson_catchme Quote Link to comment Share on other sites More sharing options...
anderson_catchme Posted September 6, 2014 Author Share Posted September 6, 2014 More info here: https://github.com/hayageek/jquery-upload-file Quote Link to comment Share on other sites More sharing options...
anderson_catchme Posted September 7, 2014 Author Share Posted September 7, 2014 Ok so I've narrowed the problem: <script type="text/javascript"> function submitform() { document.myform.submit(); } </script> <script> $(document).ready(function() { uploadObj = $("#fileuploader").uploadFile({ url:"/jquery-upload-file-master/php/upload.php", fileName:"myfile", onSuccess:function(files,data,xhr) { $('.ajax-file-upload-statusbar').delay(2000).slideUp('slow'); //Problem lies here with submitform() submitform(); }, onError: function(files,status,errMsg) { $("#status").html("<font color='red'>Upload is Failed</font>"); } }); }); </script> <br/> <form name='myform' action="createnewpost.php?4" method="POST"> <button id='my_button' name='submit' value='submit' class='btn btn-primary' onclick="event.preventDefault(); uploadObj.startUpload();"> Create Post</button> </form> </body> </html> Narrowed the problem: The form submission was interfering with fileupload. Now I just need submit get the form with submitform(); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.