PHP不呈现HTML

时间:2014-10-15 16:55:12

标签: php html

我正在用PHP编写图像管理脚本。所有关于图像管理的PHP代码都可以正常工作。问题是脚本无法在顶部呈现少量的html,包括动画加载gif。

根据要管理的图像数量,可能需要一些时间,因此我希望顶部的html呈现。我试图将它放在一个函数中,然后在html之后调用该函数,但脚本直接进行图像处理。

此页面将从Iframe中的其他网页调入iframe。

<?php
    $level = '../../';

    include('class.upload.php');    
    $folder = $_REQUEST['folder'];  

# render success page
    echo '<html><body>';
    echo '<h3 style="color: red">Processing...</h3>';
    echo 'This might take awhile... Your patience is much appreciated.';
    echo '<br><br><br><div style="text-align: center"><img src="ajaxloader.gif"></div>';
    echo '</body></html>';  


    $icon = $_REQUEST['icon'];
    $thumb = $_REQUEST['thumb'];
    $small = $_REQUEST['small'];
    $medium = $_REQUEST['medium'];
    $large = $_REQUEST['large'];
    $xlarge = $_REQUEST['xlarge'];

    foreach(glob('images/temp/*') as $image) {
    if($icon >= 1){copy($image, 'images/100/' . basename($image));}
    if($thumb >= 1){copy($image, 'images/150/' . basename($image));}
    if($small >= 1){copy($image, 'images/320/' . basename($image));}
    if($medium >= 1){copy($image, 'images/640/' . basename($image));}
    if($large >= 1){copy($image, 'images/960/' . basename($image));}
    if($xlarge >= 1){copy($image, 'images/1280/' . basename($image));}
    }



# xlarge folder     
    $startdir= 'images/1280/';
$dir="$startdir$subdir";$array_dir=array();$array_file=array();if(is_dir($dir)){if($dh=opendir($dir)){while(($file=readdir($dh))!==false){$filename=$file;$filetype=filetype($dir.$file);if($filename==".."OR$filename=="."){echo"";}else{if($filetype=="file"){$array_file[]=$filename;}elseif($filetype=="dir"){$array_dir[]=$filename;}}}closedir($dh);}}sort($array_dir);   

    foreach ($array_file as $image_file){   
    list($width, $height) = getimagesize($startdir.$image_file);
        if($width >= 1280){
            $handle = new upload($startdir.$image_file);
            if ($handle->uploaded) {
                $handle->file_name_body_add   = '_large';
                $handle->image_resize         = true;
                $handle->image_x              = 1280;
                $handle->image_ratio_y        = true;
                $handle->process($folder.'/1280/');
                if ($handle->processed) {$handle->clean();} 
                else {echo 'error : ' . $handle->error;}
            }
        }        
    }

# large folder      
    $startdir= 'images/960/';
$dir="$startdir$subdir";$array_dir=array();$array_file=array();if(is_dir($dir)){if($dh=opendir($dir)){while(($file=readdir($dh))!==false){$filename=$file;$filetype=filetype($dir.$file);if($filename==".."OR$filename=="."){echo"";}else{if($filetype=="file"){$array_file[]=$filename;}elseif($filetype=="dir"){$array_dir[]=$filename;}}}closedir($dh);}}sort($array_dir);   

    foreach ($array_file as $image_file){   
    list($width, $height) = getimagesize($startdir.$image_file);
        if($width >= 960){
            $handle = new upload($startdir.$image_file);
            if ($handle->uploaded) {
                $handle->file_name_body_add   = '_large';
                $handle->image_resize         = true;
                $handle->image_x              = 960;
                $handle->image_ratio_y        = true;
                $handle->process($folder.'/960/');
                if ($handle->processed) {$handle->clean();} 
                else {echo 'error : ' . $handle->error;}
            }
        }        
    }

# medium folder     
    $startdir= 'images/640/';
$dir="$startdir$subdir";$array_dir=array();$array_file=array();if(is_dir($dir)){if($dh=opendir($dir)){while(($file=readdir($dh))!==false){$filename=$file;$filetype=filetype($dir.$file);if($filename==".."OR$filename=="."){echo"";}else{if($filetype=="file"){$array_file[]=$filename;}elseif($filetype=="dir"){$array_dir[]=$filename;}}}closedir($dh);}}sort($array_dir);   

    foreach ($array_file as $image_file){   
    list($width, $height) = getimagesize($startdir.$image_file);
        if($width >= 640){
            $handle = new upload($startdir.$image_file);
            if ($handle->uploaded) {
                $handle->file_name_body_add   = '_large';
                $handle->image_resize         = true;
                $handle->image_x              = 640;
                $handle->image_ratio_y        = true;
                $handle->process($folder.'/640/');
                if ($handle->processed) {$handle->clean();} 
                else {echo 'error : ' . $handle->error;}
            }
        }        
    }

# small folder      
    $startdir= 'images/320/';
$dir="$startdir$subdir";$array_dir=array();$array_file=array();if(is_dir($dir)){if($dh=opendir($dir)){while(($file=readdir($dh))!==false){$filename=$file;$filetype=filetype($dir.$file);if($filename==".."OR$filename=="."){echo"";}else{if($filetype=="file"){$array_file[]=$filename;}elseif($filetype=="dir"){$array_dir[]=$filename;}}}closedir($dh);}}sort($array_dir);   

    foreach ($array_file as $image_file){   
    list($width, $height) = getimagesize($startdir.$image_file);
        if($width >= 320){
            $handle = new upload($startdir.$image_file);
            if ($handle->uploaded) {
                $handle->file_name_body_add   = '_large';
                $handle->image_resize         = true;
                $handle->image_x              = 320;
                $handle->image_ratio_y        = true;
                $handle->process($folder.'/320/');
                if ($handle->processed) {$handle->clean();} 
                else {echo 'error : ' . $handle->error;}
            }
        }        
    }

# thumb folder      
    $startdir= 'images/150/';
$dir="$startdir$subdir";$array_dir=array();$array_file=array();if(is_dir($dir)){if($dh=opendir($dir)){while(($file=readdir($dh))!==false){$filename=$file;$filetype=filetype($dir.$file);if($filename==".."OR$filename=="."){echo"";}else{if($filetype=="file"){$array_file[]=$filename;}elseif($filetype=="dir"){$array_dir[]=$filename;}}}closedir($dh);}}sort($array_dir);   

    foreach ($array_file as $image_file){   
    list($width, $height) = getimagesize($startdir.$image_file);
        if($width >= 150){
            $handle = new upload($startdir.$image_file);
            if ($handle->uploaded) {
                $handle->file_name_body_add   = '_large';
                $handle->image_resize         = true;
                $handle->image_x              = 150;
                $handle->image_ratio_y        = true;
                $handle->process($folder.'/150/');
                if ($handle->processed) {$handle->clean();} 
                else {echo 'error : ' . $handle->error;}
            }
        }        
    }

# icon folder       
    $startdir= 'images/100/';
$dir="$startdir$subdir";$array_dir=array();$array_file=array();if(is_dir($dir)){if($dh=opendir($dir)){while(($file=readdir($dh))!==false){$filename=$file;$filetype=filetype($dir.$file);if($filename==".."OR$filename=="."){echo"";}else{if($filetype=="file"){$array_file[]=$filename;}elseif($filetype=="dir"){$array_dir[]=$filename;}}}closedir($dh);}}sort($array_dir);   

    foreach ($array_file as $image_file){   
    list($width, $height) = getimagesize($startdir.$image_file);
        if($width >= 100){
            $handle = new upload($startdir.$image_file);
            if ($handle->uploaded) {
                $handle->file_name_body_add   = '_large';
                $handle->image_resize         = true;
                $handle->image_x              = 100;
                $handle->image_ratio_y        = true;
                $handle->process($folder.'/100/');
                if ($handle->processed) {$handle->clean();} 
                else {echo 'error : ' . $handle->error;}
            }
        }        
    }   
# unlink temp folder images
    $startdir= 'images/temp/';
$dir="$startdir$subdir";$array_dir=array();$array_file=array();if(is_dir($dir)){if($dh=opendir($dir)){while(($file=readdir($dh))!==false){$filename=$file;$filetype=filetype($dir.$file);if($filename==".."OR$filename=="."){echo"";}else{if($filetype=="file"){$array_file[]=$filename;}elseif($filetype=="dir"){$array_dir[]=$filename;}}}closedir($dh);}}sort($array_dir);   

    foreach ($array_file as $image_file){unlink($startdir.$image_file);}

    echo '<Script language="javascript">window.location="success.php"</script>';
?

&GT;

非常感谢任何帮助, 皮特

0 个答案:

没有答案