resize ... failed open

Programovacie jazyky, rady, poradňa...
etel
Light Star
Light Star
Používateľov profilový obrázok
Príspevky: 232
Registrovaný: 16 okt 2006, 10:37
Kontaktovať používateľa:

resize ... failed open

Príspevok od používateľa etel »

mam tento kod a neviem kde mam chybu na localhoste mi to ide ok ale na serveri mi vyhadzuje varovanie ze sa neda otvorit subor do ktoreho sa ma zapisat obrazok ....

Kód: Vybrať všetko

<?
$IMG_ORG_HEIGHT    = "*";
$IMG_ORG_WIDTH  = "*"; 
$IMG_HEIGHT = "450"; 
$IMG_WIDTH  = "450";
$IMG_ROOT = "./"; 
$use_imagecreatetruecolor = true; 
$use_imagecopyresampled      = true;
$JPG_QUALITY    =    80;

if(!$f_res = resizer_main("images/c.jpg","_",$IMG_WIDTH,$IMG_HEIGHT))die("error");
$fs_org= filesize("$IMG_ROOT/$f_org" );

$html =<<< EHTML
	<img src="$IMG_ROOT/$f_res" $sz_res[3]>
EHTML;

echo $html;

function resizer_main($image, $prefix, $w, $h){
	global $use_imagecreatetruecolor, $use_imagecopyresampled, $IMG_ROOT, 
	$JPG_QUALITY, $HTTP_POST_FILES;
	$image_name = "dsdsaa.jpg";
	//$image = "nick.JPG";

	if(trim($image) == "" || trim($image) =="none") return false;

    $arr_img = imagecreatefromgd2($image);
    if( $arr_img["w"] != $w && $arr_img["h"] != $h){
        $wh    = get_sizes($arr_img["w"], $arr_img["h"], $w, $h);
        $img_res = img_get_resized($arr_img["img"], $arr_img["w"], $arr_img["h"], $wh["w"], $wh["h"], $use_imagecreatetruecolor, $use_imagecopyresampled);
    } else {
        $img_res = $arr_img["img"];
    }
    $file_name = "dddd.gif";
	//$file_name = make_filename($image_name, $prefix);
    imagegif($img_res, $IMG_ROOT.$prefix.$file_name, $JPG_QUALITY);
    return $prefix."".$file_name."";
}

function image_from_upload($uploaded_file){
    $img_sz =  getimagesize( $uploaded_file );switch( $img_sz[2] ){
        case 1:
            $img_type = "GIF";
            die("<br><font color=\"red\"><b>Sorry, Only JPG's are supported.</b></font><br>");
        break;
        case 2:
            $img = ImageCreateFromJpeg($uploaded_file);
            $img_type = "JPG";
        break;
        case 3:
            $img = ImageCreateFromPng($uploaded_file);
            $img_type = "PNG";
        break;
        case 4:           
            $img_type = "SWF";
            die("<br><font color=\"red\"><b>Sorry, Only JPG's are supported.</b></font><br>");
        break;
        default: die("<br><font color=\"red\"><b>Sorry, Only JPG's are supported.</b></font><br>");
    }
    return array("img"=>$img, "w"=>$img_sz[0], "h"=>$img_sz[1], "type"=>$img_sz[2], "html"=>$img_sz[3]);
}


function get_sizes($src_w, $src_h, $dst_w,$dst_h ){
    $mlt_w = $dst_w / $src_w;
    $mlt_h = $dst_h / $src_h;
    $mlt = $mlt_w < $mlt_h ? $mlt_w:$mlt_h;
    if($dst_w == "*") $mlt = $mlt_h;
    if($dst_h == "*") $mlt = $mlt_w;
    if($dst_w == "*" && $dst_h == "*") $mlt=1;
    $img_new_w =  round($src_w * $mlt);
    $img_new_h =  round($src_h * $mlt);
    return array("w" => $img_new_w, "h" => $img_new_h, "mlt_w"=>$mlt_w, "mlt_h"=>$mlt_h,  "mlt"=>$mlt);
}

function 
	img_get_resized($img_original,$img_w,$img_h,$img_new_w,$img_new_h,$use_imagecreatetruecolor=false, 
	$use_imagecopyresampled=false){
    if( $use_imagecreatetruecolor && 
	function_exists("imagecreatetruecolor")){
        $img_resized = imagecreatetruecolor($img_new_w,$img_new_h) or 
	die("<br><font color=\"red\"><b>Failed to create destination image.</b></font><br>");
    } else {
        $img_resized = imagecreate($img_new_w,$img_new_h) or 
	die("<br><font color=\"red\"><b>Failed to create destination image.</b></font><br>");

    }
    if($use_imagecopyresampled && function_exists("imagecopyresampled")){
        imagecopyresampled($img_resized, $img_original, 0, 0, 0, 0,$img_new_w, $img_new_h, $img_w,$img_h) or die("<br><font color=\"red\"><b>Failed to resize @ ImageCopyResampled()</b></font><br>");
    }else{
        imagecopyresized($img_resized, $img_original, 0, 0, 0, 0,$img_new_w, $img_new_h, $img_w,$img_h) or die("<br><font color=\"red\"><b>Failed to resize @ ImageCopyResized()</b></font><br>");
    }
    return $img_resized;
}

function make_filename($image_name){
    $file_name = uniqid('s').'.jpg';
    $pos = strrpos($file_name, '.');
    $file_name = substr($file_name, 0,$pos).".jpg";
    return $file_name;
}

?>
caesar1987
Addict
Addict
Používateľov profilový obrázok
Príspevky: 3001
Registrovaný: 02 okt 2005, 0:57
Bydlisko: Nové Zámky
Kontaktovať používateľa:

Príspevok od používateľa caesar1987 »

mas nastavene prava priecinka??
etel
Light Star
Light Star
Používateľov profilový obrázok
Príspevky: 232
Registrovaný: 16 okt 2006, 10:37
Kontaktovať používateľa:

Príspevok od používateľa etel »

nj ved to je to chmod nie .... nastavil som tak ze je vsetko povolene .... a uz mi ukazuje

Kód: Vybrať všetko

Fatal error: Call to undefined function: imagegif() in D:\www\upload\upload.php on line 
asi tam ma byt ina funkia asi som to zmenil a neviem aka bola ta povodna
etel
Light Star
Light Star
Používateľov profilový obrázok
Príspevky: 232
Registrovaný: 16 okt 2006, 10:37
Kontaktovať používateľa:

Príspevok od používateľa etel »

moze byt LOCK uz som to vyriesil
Napísať odpoveď