display loading message in php self submit form

I have any form for upload video, this worked using PHP / MySQL and submit PHP_SELF action. If upload video = TRUE I print video is success and if upload video = FALSE I print error message.

Now I need to show display loading message or loading gif animator (using jQuery) after clicking the submit button and hidding the loading message after showing the TRUE/FALSE upload message. Any way to create this?

My form:

<?PHP
if (isset($_POST['submit']) && $_POST['submit'] == 'uploadvideo')
     {
      //CHECK TRUE OR FALSE .....
     }
if (isset($uploaded) && $uploaded == TRUE){?>
     <div class="successbox">success upload!!!</div>
<?PHP } 
if (isset($uploaded) && $uploaded == FALSE)
    {?>
     <div class="errorbox">error upload!!!</div>
<?PHP } ?>

    <form action="<?PHP echo URL . '/video.php?id=' . int($_GET['id']);?>" method="POST" enctype="multipart/form-data">
      <table width="100%" cellpadding="5" cellspacing="0" border="0">
      <input type="file" size="40" name="video_file" maxlength="50">
      <input type="Submit" name="submit" value="uploadvideo">
      </table>
      </form>

Answers


The easiest an quickest solution is to add a hidden <div> element to your form containing a loading message or animated gif, and when you click the submit button you show the <div> tag using jQuery:

<form action="..." method="POST" enctype="multipart/form-data" onsubmit="$('#loading').show();">
  <div id="loading" style="display:none">Uploading...</div>

  <table width="100%" cellpadding="5" cellspacing="0" border="0">
    <input type="file" size="40" name="video_file" maxlength="50">
    <input type="Submit" name="submit" value="uploadvideo">
  </table>
</form>

If you want something more fancy (like an actual progress bar) you'll need to look into a flash solution (like swfupload).

Starting with PHP 5.4 you can also find the upload progress in _SESSION (more details here) but seeing as PHP 5.4 is just released, you wont find many webhosts that already have this.


Need Your Help

How to include hbci4java (a java ANT project hosted on github) into a SBT scala application?

git scala maven ant sbt

I'm writing a scala application (playframework 2.3.1) and want to use hbci4java (https://github.com/willuhn/hbci4java).

DocumentDb Spatial Distance in Linq returns weird result

c# linq azure azure-documentdb

When I do a documentdb linq distance query on two Points (Microsoft.Azure.Documents.Spatial) that are the same I get different results.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.