[PHP] iki farklı resim yükleme problemi


Üyelik Yaşı
3 Ay
Mesajlar
1,294
Tepki Puanı
509
Ödül
161
Konum
Kocaeli
Arkadaşlar 2 adet upload butonum var (logo / favicon) bu ikisinin uploadını nasıl sağlayabilirim Kodlar:
PHP:
$fileNameLogo = @$_FILES['stSiteLogo']['name'];
            $fileSizeLogo = @$_FILES['stSiteLogo']['size'];
            $fileTmpNameLogo = @$_FILES['stSiteLogo']['tmp_name'];
            $fileTypeLogo = @$_FILES['stSiteLogo']['type'];
            $fileExtensionsLogo = ['jpeg','jpg','png'];
            $fileExtensionLogo = strtolower(end(explode('.',$fileNameLogo)));
            $fileNameEncodedLogo = hash("sha1", basename($fileNameLogo)."-".bin2hex(openssl_random_pseudo_bytes(32))).".".$fileExtensionLogo;
            $uploadPathLogo = "upload/logo".$fileNameEncodedLogo;
            $fileNameFavicon = @$_FILES['stSiteFavicon']['name'];
            $fileSizeFavicon = @$_FILES['stSiteFavicon']['size'];
            $fileTmpNameFavicon = @$_FILES['stSiteFavicon']['tmp_name'];
            $fileTypeFavicon = @$_FILES['stSiteFavicon']['type'];
            $fileExtensionsFavicon = ['jpeg','jpg','png'];
            $fileExtensionFavicon = strtolower(end(explode('.',$fileNameFavicon)));
            $fileNameEncodedFavicon = hash("sha1", basename($fileNameFavicon)."-".bin2hex(openssl_random_pseudo_bytes(32))).".".$fileExtensionFavicon;
            $uploadPathFavicon = "upload/favicon".$fileNameEncodedFavicon;
$uploadMessageNumber = 0;
                $queryUpdateSetting = $dbh->prepare("UPDATE setting SET setting_value = :setting_value WHERE setting_name = :setting_name");
                if(isset($fileNameLogo)){
                    if (!in_array($fileExtensionLogo,$fileExtensionsLogo)) {
                        echo "extension";
                    }else{
                        if ($fileSizeLogo > 5000000) {
                            echo "limit";
                        }else{
                            move_uploaded_file($fileTmpName, $uploadPathLogo);
                            $queryUpdateSetting->execute(array(
                                ":setting_value" => $uploadPathLogo,
                                ":setting_name" => "st_logo"
                            ));
                        }
                    }
                }              
                if(isset($fileNameFavicon)){
                    if (!in_array($fileExtensionFavicon,$fileExtensionsFavicon)) {
                        echo "extension";
                    }else{
                        if ($fileSizeFavicon > 5000000) {
                            echo "limit";
                        }else{
                            move_uploaded_file($fileTmpName, $uploadPathFavicon);
                            $queryUpdateSetting->execute(array(
                                ":setting_value" => $uploadPathFavicon,
                                ":setting_name" => "st_favicon"
                            ));
                        }
                    }
                }
 
Son düzenleme:

Son Eklenenler Yazılar

Üst