• 21-04-2010, 21:17:37
    #1
    Aşağıdaki Resim Upload Kodu Başarılı Bir Şekilde Çalışıyor Fakat Resim İsmine 5 Haneli Rand Oluşturdum Ama
    resim/images/a7a5aKış.jpg Bu Şekilde Resmi Gönderiyor Türkçe Karakterleri Nereye Ve nasıl Bir Kod Gömmeliyimki Bul Değiştir Yapsın. Ustalarıma Yardımcı Olduğu İçin Şimdiden Teşekkür Ederim

    <?php
    $idir = "http://forum.ceviz.net/images/"; //orjinal resmin koyulacağı klasör
    $tdir = "thumbs/"; // küçültülen dosyanın koyulacağı klasör
    $twidth = "125"; // küçültülen resimin maximum genişlik
    $theight = "100"; // küçültülen resimin Maximum yükseklik
    $rand =substr(md5(uniqid(rand())),0,5);
    
    
    
    
    if (!isset($_GET['yontem'])) { // atama yapılmamışsa formu göster ?>
    
    <form method="post" action="index.php?yontem=upload" enctype="multipart/form-data">
    File:<br />
    <input type="file" name="resim" class="form">
    <br /><br />
    <input name="submit" type="submit" value="Gönder" class="form"> <input type="reset" value="sil" class="form">
    </form>
    
    
    
    
    <? }
    else if (isset($_GET['yontem']) && $_GET['yontem'] == 'upload')
    {
    $url = $_FILES['resim']['name'];
    
    if ($_FILES['resim']['type'] == "image/jpg" || $_FILES['resim']['type'] == "image/jpeg" || $_FILES['resim']['type'] == "image/pjpeg")
    {
    $file_ext = strrchr($_FILES['resim']['name'], '.');
    $copy = copy($_FILES['resim']['tmp_name'], "$idir/".$rand.$_FILES['resim']['name']);
    
    if ($copy) {
    print 'Image uploaded successfully.<br />';
    $simg = imagecreatefromjpeg("$idir".$rand. $url);
    $currwidth = imagesx($simg);
    $currheight = imagesy($simg);
    if ($currheight > $currwidth) {
    $zoom = $twidth / $currheight;
    $newheight = $theight;
    $newwidth = $currwidth * $zoom;
    } else {
    $zoom = $twidth / $currwidth;
    $newwidth = $twidth;
    $newheight = $currheight * $zoom;
    }
    $dimg = imagecreate($newwidth, $newheight);
    imagetruecolortopalette($simg, false, 256);
    $palsize = ImageColorsTotal($simg);
    for ($i = 0; $i < $palsize; $i++) {
    $colors = ImageColorsForIndex($simg, $i);
    ImageColorAllocate($dimg, $colors['red'], $colors['green'], $colors['blue']);
    }
    imagecopyresized($dimg, $simg, 0, 0, 0, 0, $newwidth, $newheight, $currwidth, $currheight);
    imagejpeg($dimg, "$tdir".$rand. $url);
    imagedestroy($simg);
    imagedestroy($dimg);
    print 'Image thumbnail created successfully.';
    } else {
    print '<font color="#FF0000">HATA: Resim Upload Edilemedi.</font>';
    }
    } else {
    print '<font color="#FF0000">Hata: Resim dosyası değil (.jpg veya .jpeg. dosyaları ';
    print $file_ext;
    print '.</font>';
    }
    } 
    ?>
  • 21-04-2010, 22:30:14
    #2
    halletim Teşekkürler