当我在IE8中上传图像时,页面不能被重定向


Page can't be redirect when i upload image which that form in IE8

这是我的添加和编辑数据的功能,在我的形式中,当我上传图像时,我调用validateProdImage()函数来上传图像,但此代码在IE8中不工作,此代码在firefox和crome中工作良好。

//for add and edit product
function addEditProduct(){
    $this->setGetVars();
    $this->setPostVars();
    if(!$this->submit || $this->submit != 1) return;
    // Validate image type and image size
    if($this->prod_image['name'])
        $this->validateProdImage();
    if($this->action == "add") {
        // Check if the Product already exist
        $q = "AND  prod_name = '".$this->prod_name."'";
        if($this->getCntProduct($q) > 0)  
            $this->setMessage("Product already exist!", "error");
        else {

            // Adding New Product
            $query = "INSERT INTO tbl_product SET
                    prod_id     = '',
                    prod_name   = '".addslashes($this->prod_name)."',
                    prod_code   = '".addslashes($this->prod_code)."',
                    prod_image  = '',
                    prod_weight = '".addslashes($this->prod_weight)."',
                    prod_type   = '".$this->prod_type."',
                    prod_desc   = '".addslashes($this->prod_desc)."',
                    prod_price  = '".$this->prod_price."',
                    prod_stock  = '".$this->prod_stock."',
                    prod_status = '".$this->prod_status."'";
            $this->connect->executeQuery($query, $this->connect->conn);
            $this->last_insert_id = $this->connect->insert_id;
            // Saving image
                if($this->prod_image['name'])
                    $this->prod_image_name = $this->saveProductImage();
                $query = "UPDATE tbl_product SET
                prod_image = '".$this->prod_image_name."' WHERE prod_id =".$this->last_insert_id;   
                $this->connect->executeQuery($query, $this->connect->conn); 
            $this->setMessage("Product has been addedd successfully!", "success");
            header("refresh:1; url=index.php?cnt=product&act=list&rs=1");
        }
    } else if($this->action == "edit") {
        $image = "";
        // For update image we check if new image availbale then we can call this function  
        if($this->prod_image['name']) {
            $this->prod_image_name = $this->saveProductImage();
            $image = "prod_image   = '".$this->prod_image_name."',";
        }
        // Edit Product details
        $query = "UPDATE tbl_product SET
                prod_name   = '".addslashes($this->prod_name)."',
                prod_code   = '".addslashes($this->prod_code)."',
                ".$image."
                prod_weight = '".addslashes($this->prod_weight)."',
                prod_type   = '".$this->prod_type."',
                prod_desc   = '".addslashes($this->prod_desc)."',
                prod_price  = '".$this->prod_price."',
                prod_stock  = '".$this->prod_stock."',
                prod_status = '".$this->prod_status."' WHERE prod_id = '".$this->prod_id."' LIMIT 1";
        $this->connect->executeQuery($query, $this->connect->conn);
        $this->setMessage("Product details has been edited successfully!", "success");
        header("refresh:1; url=index.php?cnt=product&act=list&rs=1");
    }
}
    // Save Product Image
function saveProductImage() {
    $imagename = "";
    $temppath = $this->prod_image['tmp_name'];
    $extention = explode("/",$this->prod_image['type']);
    if(isset($this->last_insert_id))        
        $imagename = $this->last_insert_id."_".time().".".$extention[1];
    else
        $imagename = $this->prod_id."_".time().".".$extention[1];
    $filepath = PRODUCT_UPLOAD_DIR.$imagename;
    if($this->prod_image_name)
        if(file_exists(PRODUCT_UPLOAD_DIR.$this->prod_image_name))
            unlink(PRODUCT_UPLOAD_DIR.$this->prod_image_name);
    move_uploaded_file($temppath,$filepath);
    return $imagename;
}

代替

header("refresh:1; url=index.php?cnt=product&act=list&rs=1");
使用

sleep(1);
header("Location: /index.php?cnt=product&act=list&rs=1");