[Linux-programlama] Post data problem

---------

New Message Reply About this list Date view Thread view Subject view Author view Attachment view

From: Yunus Emre Köse (godpenguin@gmail.com)
Date: Sun 31 Jul 2005 - 13:27:14 EEST


Selamlar,

 

Gecenlerde bir fonksiyonun bir imaji bir yere kaydetme konusunda problemim
vardi. Sizin sayenizde cozulmustu. Simdi o sorunun devami olarak bir
problemim daha var.

 

 

 

Asagidaki fonksiyonda POST tan gelen bir imaji kullanabilir hale nasil
getirebilirim. Fonksiyon bir imaji thumbnail haline getiriyor. Problem su:
Fonksiyon gelen datayi

Uzantisinin jpeg ya da png ya da gif olmasina gore isliyor ve thumbnail
haline getiriyor. Ancak POST tan gelen datayi php tmp uzantili olarak
kaydettigi icin dosyayi bu fonksiyon da kullanamiyorum.

 

Ayrica gelen datayi move_uploaded_file fonksiyonu ile diske kaydetip tekrar
o dosyayi bu fonksiyona gonderdigim zamanda neden oldgunu anlayamadigim bir
sekilde

yine okuyamiyor. Ama ben okuyabilir olsa bile iki is yaptirmak istemiyorum.
Cunku imajin sadece thumbnail hali gerekiyor.

 

Kullanimim su sekilde :

 

move_uploaded_file($_FILES['form_data']['tmp_name'], $uploadfile);

createthumb('$_FILES[form_data][name]','$dosya',150,150);

 

 

Sorum: Formdan gelen bilgiyi bu fonksiyonda kullanabilir hale nasil
getirebilirim?

 

Yine ayni fonksiyon:

 

function createthumb($name,$filename,$new_w,$new_h)

{

            $system=explode(".",$name);

            if
(preg_match("/jpg|jpeg/",$system[1])){$src_img=imagecreatefromjpeg($name);}

            if
(preg_match("/png/",$system[1])){$src_img=imagecreatefrompng($name);}

        if
(preg_match("/gif/",$system[1])){$src_img=imagecreatefromgif($name);}

            $old_x=imageSX($src_img);

            $old_y=imageSY($src_img);

            if ($old_x > $old_y)

            {

                        $thumb_w=$new_w;

                        $thumb_h=$old_y*($new_h/$old_x);

            }

            if ($old_x < $old_y)

            {

                        $thumb_w=$old_x*($new_w/$old_y);

                        $thumb_h=$new_h;

            }

            if ($old_x == $old_y)

            {

                        $thumb_w=$new_w;

                        $thumb_h=$new_h;

            }

            $dst_img=ImageCreateTrueColor($thumb_w,$thumb_h);

 
imagecopyresampled($dst_img,$src_img,0,0,0,0,$thumb_w,$thumb_h,$old_x,$old_y
);

            if (preg_match("/png/",$system[1]))

            {

                 imagepng($dst_img,$filename);

            }

        else if (preg_match("/jpg|jpeg/",$system[1])) {

                 imagejpeg($dst_img,$filename);

            }

        else if (preg_match("/gif/",$system[1])) {

                 imagegif($dst_img,$filename);

            }

        

            imagedestroy($dst_img);

            imagedestroy($src_img);

}

_______________________________________________
Linux-programlama mailing list
Linux-programlama@liste.linux.org.tr
http://liste.linux.org.tr/mailman/listinfo/linux-programlama


New Message Reply About this list Date view Thread view Subject view Author view Attachment view

---------

Bu arsiv hypermail 2.1.2 tarafindan uretilmistir.