0

I have an image upload form, which auto uploads the image when user selects the file.

Upload form

<form id="imageupload" action="./uploadres.php" enctype="multipart/form-data" method="post">
<input type="file" name="file" value="Ekle" accept="image/*" size="20">
</form>

Auto upload script when user selected file

$("input[name='file']").change(function() {

this.form.submit(); 

});

Show/hide loading image function:

$('#loadimg').show();
$('#contents').load(function(){
$('#loadimg').hide();
});

What I am trying to do is showing loading image while its uploading. What is the correct way to integrate the Show/hide loading image method into my form submit ?

user198989
  • 4,092
  • 17
  • 57
  • 85

1 Answers1

2

If you are doing a full HTML post, then you only have one option:

Using the form's onsubmit event to display the uploading symbol. This will be cleared when the new HTML is downloaded.

On the other hand, if you are using jQuery to submit the form, there are a several excellent ways to handle that.

I'd point you to this discussion for an overview.

Community
  • 1
  • 1
Jeremy J Starcher
  • 21,760
  • 5
  • 48
  • 70