一个表单 是实现大文件上传功能的,基本上等待一分钟都是很正常的事,所以必须要做一个提示了,不然用户以为失去响应了。
假如表单如下,当用户点击 提交 按钮之后,如何显示一个  提示文字,或者一个提示图片。 当完全执行完毕后,再隐藏起来。
<form name="form1" method="post" action="aaa.php" encType=multipart/form-data>
  <input id=filename 
      onKeyDown="return DisWrite()" 
      style="BORDER-RIGHT: #73aaad 1px solid; BORDER-TOP: #73aaad 1px solid; BORDER-LEFT: #73aaad 1px solid; COLOR: #3a493a; BORDER-BOTTOM: #73aaad 1px solid; BACKGROUND-COLOR: #e3eae3" 
      type=file  size=25 name=filename >
  <input type="submit" name="Submit" value="提交">
</label>
</form>

解决方案 »

  1.   

    用div做一个遮罩层 放一个不断转动的图片 默认先隐藏
    提交时加多个事件 让层显示
      

  2.   

    //这个方法是上传图片的,不过也是先了楼主的效果
    <?php
    if(!isset($_SESSION))session_start();/**2010-6-22
     * $data 数组类型 包含以下变量
     -------------------------------
     * $sub_type submit类型(upload:上传按钮 delete:删除按钮),默认upload
     * $file 通过表单获取的$_FILES['filename']数组
     * $img_tag_id 预览图片的<img>的ID值
     * $img_dir 上传图片的目录
     * $max_file_size 单位M(兆),默认:1M
     * $type_array 允许的上传的图片类型(默认:image/pjpeg、image/jpeg、image/gif)
     **/
    function upload($data){
    if(!$data['file']){
    echo '<script>alert("file不能为空!");</script>';exit;
    }
    if(!$data['img_tag_id']){
    echo '<script>alert("预览图片标签ID不能为空!");</script>';exit;
    }
    if(!$data['img_dir']){
    echo '<script>alert("图片上传目录不能为空!");</script>';exit;
    }
    if(!isset($data['max_file_size'])){
    $data['max_file_size'] = 1024 * 1024;
    }else{
    $data['max_file_size'] = $data['max_file_size'] * 1024 * 1024;
    }
    if(!isset($data['type_array'])){
    $data['type_array'] = array('image/pjpeg', 'image/jpeg', 'image/gif');
    }
    if(!isset($data['sub_type'])){
    $data['sub_type'] = 'upload';
    } $refer = $_SERVER['HTTP_REFERER'];
    $imgpath = '';
    if(isset($data['sub_type']) && $data['sub_type'] == 'delete'){
    if(isset($_SESSION['name']) && $_SESSION['name']){
    if(is_file($_SESSION['imgpath'])){
    $b = unlink($_SESSION['imgpath']);
    }
    unset($_SESSION['name'], $_SESSION['imgpath']);
    if(!isset($_SESSION['name'])){
    echo '<script>alert("删除成功!");</script>';
    echo '<script>parent.document.getElementById("'.$data['img_tag_id'].'").style.display = "none";</script>';
    echo '<script>location.href = "'.$refer.'";</script>';
    }else{
    echo '<script>alert("删除失败!");</script>';
    }
    }else{
    echo '<script>alert("没有稿件!");</script>';
    }exit;
    } if(isset($_SESSION['imgpath']) && $_SESSION['imgpath']){
    echo '<script>alert("稿件已经存在,要想重新上传请删除原来的稿件!");</script>';exit;
    }
    if(!in_array($data['file']['type'], $data['type_array'])){
    echo '<script>alert("稿件类型不匹配,请上传.jpg、.gif和.png格式的图片!");</script>';exit;
    }
    if($data['file']['size'] > $data['max_file_size']){
    echo '<script>alert("您上传的稿件过大,请选择2M以下的图片上传!");</script>';exit;
    } if(!is_dir($data['img_dir'])){
    @mkdir($data['img_dir'], 0777, true);
    }
    $imgpath = $data['img_dir'].'/'.date('His', time()).rand(100, 999).$data['file']['name'];
    $isupload = move_uploaded_file($data['file']['tmp_name'], $imgpath);
    if(!$isupload){
    echo '<script>alert("稿件上传失败,请尝试重新上传!");</script>';
    }else{
    echo '<script>alert("稿件上传成功!");</script>';
    }
    $_SESSION['name'] = $data['file']['name'];
    $_SESSION['imgpath'] = $imgpath; return $imgpath;
    }/*test_start*/
    $sub_type = '';
    if(isset($_POST['submit_upload']))$sub_type = 'upload';
    if(isset($_POST['submit_delete']))$sub_type = 'delete';
    if($sub_type){//echo '<script>alert("'.$sub_type.'");</script>';exit;
    $data = array( 'sub_type' => $sub_type,
    'file' => $_FILES['file'],
    'img_tag_id' => 'picview',
    'img_dir' => 'upload_img',
      );
    $imgpath = upload($data);
    }else{
    $imgpath = isset($_SESSION['imgpath'])? $_SESSION['imgpath']: '';
    }
    ?><form action="a.php" method="post" enctype="multipart/form-data" target="frame" onsubmit="return wait()">
    <input type="file" name="file" class="input">
    <input type="submit" name="submit_upload" value="上  传">
    <input type="submit" name="submit_delete" value="删  除"><span id="wait"></span>
    <iframe id="frame" name="frame" width="0" height="0" marginwidth="0" frameborder="0" src="about:blank"></iframe>
    </form><img id="picview" height="100" style="display:none;"><script>
    if("<?php echo $imgpath; ?>"){
    parent.document.getElementById("picview").src = "<?php echo $imgpath; ?>";
    parent.document.getElementById("picview").style.display = "block";
    document.getElementById("wait").innerHTML = "完成!";
    }function wait(){
    document.getElementById("wait").innerHTML = "请稍后...";
    }
    </script>
      

  3.   

    php5.2开始支持一个上传反馈的钩子。