Prova questi come sono.

File : test318.php
Codice PHP:
<?php 
if (isset($_GET['action'])) {
 
$action $_GET['action'];
} else {
 
$action "todo";
}
 
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled</title>
<script language="JavaScript" type="text/javascript">
<!--
function myfunction() {
 document.getElementById('pippo').innerHTML = 'Stiamo avviando il trasferimento - prego attendere';
}
//-->
</script>
</head>
<body>
<hr />
<div id="pippo"><?php 
 
if ($action == 'done') {
  print 
"File trasferito";
 } else {
  print 
"&nbsp;";
 }
 
?>
</div>
<hr />
<form action="test318b.php" method="post" onsubmit="myfunction();">
 <input type="submit" name="Submit" value="Submit" />
</form>
</body>
</html>
File : test318b.php - é importante che il file non scriva nulla a video visto che si usa header.
Codice PHP:
<?php 
 
for ($i=1;$i<=1000;$i++) {
  for (
$j=1;$j<=5000;$j++) {
  
//---- per simolare un'attesa
 
}
 }
 
header('Location:test318.php?action=done');
 exit;
?>