在PHP表单处理时加载gif

I have a PHP form which includes a file being uploaded upon submit. As I allow pretty big files, the page can often stand there loading for ages.

Is there a way to show the user a loading animation of some sort?

You'll need JQuery to use my code, but it's worth it:

Put this script tag in your site <head>:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.0/jquery.min.js"></script>

Put a hidden loading gif somewhere, wherever you want to see it

<img id="loader" src="loading.gif" />

Hide it on page load: $('#loader').hide();

Then in Javascript (or even better JQuery), inside your submit function...show/hide it:

function submit()
{
    $('#loader').show();
    // do your upload stuff
    $('#loader').hide();    
}

I would put a hidden image somewhere on the page. Call a javascript function upon form submit, and let that function display the image, before submitting the form.