Results 1 to 2 of 2

Thread: error uploading image to database!!!

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2006
    Posts
    175

    error uploading image to database!!!

    hello
    found this script but keep giving me an error in line 23!!!

    Fatal error: Call to undefined function: imagecreatefromjpeg() in c:\program files\easyphp1-8\www\taboadamacronews_port\include_img.php on line 23

    please help

    Code:
    <?
    
    // UPLOAD DA IMAGEM
    if(move_uploaded_file($upimagetemp,$thumbdir.$upimage)){
    	echo "<div align='center'><span class='fonte1'><br /><br />Arquivo $upimage enviado!</span></div>";
    } else {
    	echo "<div align='center'><span class='fonte1'><br /><br />Ocorreu um erro no envio.</span></div>";
    	include "include_footer.php";
    	exit();
    }
    
    // VARIÁVEIS DE PROCESSO DAS IMAGENS
    $imagem =$upimage;
    $imagem2=$imagem;
    
    // PEGA EXTENSÃO / VERIFICA EXTENSÃO
    $ext =explode(".",$imagem);
    $ext0=$ext[0];
    $ext1=$ext[1];
    
    if($ext1=="jpg" || $ext1=="JPG"){
    $extensao=strtolower(".".$ext1);
    $img	 =imagecreatefromjpeg($thumbdir.$imagem);
    $img2	 =imagecreatefromjpeg($thumbdir.$imagem2);
    
    // VARIAVEIS ALTURA E LARGURA PROPORCIONAIS - IMG PEQUENA
    /*
    $wi		=imagesy($img);
    $he		=imagesx($img);
    $imgwidth =$altura;
    $imgheight =$he*$imgwidth/$wi;
    */
    // VARIAVEIS ALTURA E LARGURA PROPORCIONAIS - IMG GRANDE
    $wi2=imagesy($img2);
    $he2=imagesx($img2);
    $imgwidth2=$altura2;
    $imgheight2=$he2*$imgwidth2/$wi2;
    
    // VARIAVEIS ALTURA E LARGURA IGUAIS - IMG PEQUENA
    $wi		=imagesy($img);
    $he		=imagesx($img);
    $imgwidth =$altura;
    $imgheight =$imgwidth;
    // VARIAVEIS ALTURA E LARGURA IGUAIS - IMG GRANDE
    /*
    $wi2=imagesy($img2);
    $he2=imagesx($img2);
    $imgwidth2=$altura2;
    $imgheight2=$imgwidth2;
    */
    
    // CRIA A IMAGEM PEQUENA
    $img_nova=imagecreatetruecolor($imgheight,$imgwidth);
    imagecopyresampled($img_nova,$img,0,0,0,0,$imgheight,$imgwidth,$he,$wi);
    imageinterlace($img_nova,1);
    $imagemnova=imagejpeg($img_nova,$thumbdir.$ext0.$thumb.$random.$extensao,90);
    
    // CRIA A IMAGEM GRANDE
    $img_nova2=imagecreatetruecolor($imgheight2,$imgwidth2);
    imagecopyresampled($img_nova2,$img2,0,0,0,0,$imgheight2,$imgwidth2,$he2,$wi2);
    imageinterlace($img_nova2,1);
    $imagemnova2=imagejpeg($img_nova2,$thumbdir.$ext0.$thumb2.$random.$extensao,90);
    
    // DESTRÓI MEMÓRIA ALOCADA PRAS VARIÁVEIS
    imagedestroy($img_nova);
    imagedestroy($img);
    imagedestroy($img_nova2);
    imagedestroy($img2);
    unlink($thumbdir.$imagem);
    
    $imgthumb=$ext0.$thumb.$random.".".$ext1;
    $imgthumb2=$ext0.$thumb2.$random.".".$ext1;
    
    unset($imagem);
    } else {
    	echo "<div align='center'><span class='fonte1'><br /><br />Extensão da imagem não corresponde!<br /></span></div>";
    }
    
    ?>
    Last edited by Motorui; Nov 8th, 2007 at 10:59 AM.

  2. #2
    Hyperactive Member
    Join Date
    Dec 2006
    Location
    Ubuntu Haters Club
    Posts
    405

    Re: error uploading image to database!!!

    Hi, for you to use this function the GD Library needs to be installed (which should be bundled with the distribution). Make sure it's loaded in php.ini.
    » Twitter: @rudi_visser : Website: www.rudiv.se «

    If Apple fixes security flaws, they are heralded as proactive. If Microsoft fixes a security flaw, they finally got around to fixing their buggy OS.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width