v2.5.2
Giriş yap

Dosya Yükleme Sorunu (PHP)

rennie
1,284 defa görüntülendi
<?php
include_once('../config.php');

    
    // klasör oluştur
        $kLasorAdi = uniqid().date("dmY");
        $old = umask(0);
        mkdir("../uploads/".$kLasorAdi, 0777);
        umask($old);
    // klasör oluştur
 
if(!empty($_FILES['files'])){
    $n=0;
    $s=0;
    $prepareNames   =   array();
    foreach($_FILES['files']['name'] as $val)
    {
        $infoExt        =   getimagesize($_FILES['files']['tmp_name'][$n]);
        $s++;
        $filesName      =   str_replace(" ","",trim($_FILES['files']['name'][$n]));
        $files          =   explode(".",$filesName);
        $File_Ext       =   substr($_FILES['files']['name'][$n], strrpos($_FILES['files']['name'][$n],'.'));
         
        if($infoExt['mime'] == 'image/gif' || $infoExt['mime'] == 'image/jpeg' || $infoExt['mime'] == 'image/png' || $infoExt['mime'] == 'image/jpg')
        {
            $srcPath    =   '../uploads/'.$kLasorAdi.'/';
            $fileName   =   $s.rand(0,999).time().$File_Ext;
            $path   =   trim($srcPath.$fileName);
            if(move_uploaded_file($_FILES['files']['tmp_name'][$n], $path))
            {
                $prepareNames[] .=  $fileName; //need to be fixed.
                $Sflag      =   1; // success
            }else{
                $Sflag  = 2; // file not move to the destination
            }
        }
        else
        {
            $Sflag  = 3; //extention not valid
        }
        $n++;
    }
    if($Sflag==1){
        echo '{Images uploaded successfully!}';
    }else if($Sflag==2){
        echo '{File not move to the destination.}';
    }else if($Sflag==3){
        echo '{File extention not good. Try with .PNG, .JPEG, .GIF, .JPG}';
    }
 
    if(!empty($prepareNames)){
        $count  =   1;
        foreach($prepareNames as $name){
            $data   =   array(
                            'img_name'=>$name,
                            'img_order'=>$count++,
                        );
            $db->insert(TB_IMG,$data);
        }
    }
}
?>

PHP ile çoklu resim yükleme üzerine çalışıyorum, ama bir sorun var.
Resimleri yüklerken uzantısı küçük harf ile olursa .jpg, .png gibi belirttiğim klasöre yüklüyor,
ama uzantısı .JPG, .PNG olursa büyük şekilde yüklemiyor, nasıl çözebilirim ?

ferixinder
1204 gün önce

Evet bu şekilde sorun çözülmesi gerekiyor