hayalet42 adlı üyeden alıntı: mesajı görüntüle
Dostum unuttuğun fonksiyonu hatırlasan güzel olucaktı.
upload.php
<?
if (empty($_FILES["resim"]["name"])) {
  echo '
    <script language="javascript">
        alert("Resim seçilmedi seçde gel.");
        history.back();
    </script>';
exit;
}
$kaynak = $_FILES["resim"]["tmp_name"]; 
$dosya = str_replace(" ", "_", $_FILES[resim][name]);
$uzanti = explode(".", $_FILES[resim][name]);
$hedef  = "upload/".$dosya;
if ($uzanti[1] == "jpg" || $uzanti[1] == "bmp" || $uzanti[1] == "JPG" || $uzanti[1] == "gif" || $uzanti[1] == "GIF" || $uzanti[1] == "png" || $uzanti[1] == "PNG" || $uzanti[1] == "TIF" || $uzanti[1] == "TIFF" ) {
if (file_exists($hedef)) {
    $hmz = substr(md5(uniqid(rand())),0,8);
    $hedef = "upload/$hmz-".$dosya;
    $dosya = "$hmz-".$dosya;
}
move_uploaded_file($kaynak,$hedef);
echo " dosya eklendi link: $hedef ";
} else
{ echo " geçersiz dosya tipi "; }
?>
index.php
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form name="form1" enctype="multipart/form-data" method="post" action="upload.php">
  <input name="resim" type="file" id="resim">
  <br>
  <br>
  <input name="submit" type="submit" id="submit" value="y&uuml;kle gitsin">
</form>
</body>
</html>
resmi upload klasörüne yüklüyor verdiğin kodları nasıl entegre edicem?
Yanlış Olmuş Kodlar
adam shell.jpg.php diye dosya yollarsa dosya yüklenir.
Aşağıda'ki kodlar işini görecektir yanlarına açıklamalarını yazdım
<? 
 function uzantibul($file) { 
    $array = explode('.',$file); 
    $key   = count($array) -1; 
    $ext   = $array[$key]; 
    return $ext; 
    } 
if (empty($_FILES["resim"]["name"])) { 
  echo ' 
    <script language="javascript"> 
        alert("Resim seçilmedi seçde gel."); 
        history.back(); 
    </script>'; 
exit; 
} 
$kaynak = $_FILES["resim"]["tmp_name"];  // Dosyayı tmp dizinine kaydettik
$dosya = str_replace(" ", "_", $_FILES[resim][name]);  // Gelen dosya ismi
$s=strtolower(uzantibul($dosya)); // Dosyanın Uzantısını buluyoruz jpg gif png her ne ise
$os = array("gif", "png", "jpg", "jpeg","png","bmp","tif"); // izin vermek istediğin dosya türleri 
if (!in_array($s, $os)) {  // Check ediyoruz gelen dosya türü kabul ettiklerimizdenmi diye
echo("Geçersiz dosya Türü"); 
exit();  // exit kullanıyoruz aksi taktirde işlem devam eder
} 
$hedef  = "upload/".$dosya; // Dosyanın yükleneceği konumu oluşturuyoruz
if (file_exists($hedef)) {  // Daha önce aynı isimde kayıtlı dosya varmı bakıyoruz
    $hmz = substr(md5(uniqid(rand())),0,8);  // eğer aynı isimde kayıylı dosya var ise rand sayı oluşturup 
    $hedef = "upload/$hmz-".$dosya; //dosya adına ekliyoruz
} 
move_uploaded_file($kaynak,$hedef);  // dosyayı yüklüyoruz
echo " dosya eklendi link: $hedef "; // dosya linkini yazıyoruz
?>