İyinet'e Hoşgeldiniz!

Türkiye'nin En Eski Webmaster Forum'una Hemen Kayıt Olun!

Kayıt Ol!

yüklenen resimlerdeki chmod sorunu

i.ari

0
İyinet Üyesi
Katılım
16 Aralık 2006
Mesajlar
4,437
Reaction score
6
Konum
Ankara
Merhaba arkadaşlar,
resim yüklüyorum. Yükledigim resimlerin chmodları hep 600 oluyor ftp ile denedigimde ve bakmaya çalıştıgımda kullanıcı hakkı yüzünden sorun veriyor sizce ne yapabilirim?

Klasorun chmodu 777

Yükledigim php koduda bu.

PHP:
<html>
<head> Dosya Upload</head>
<body>
<body bgcolor="#e6e2e2">
<form action="resimyukle.php" method="post" enctype="multipart/form-data">
Lütfen dosyayı Seciniz:<br>
<input type="file" name="filetoupload"><br>
<input type="hidden" name="MAX_FILE_SIZE" value="<?echo $size_bytes; ?>">
<br>
<input type="Submit" value="Dosyayi Yükle">

</form>
<?php
/*

---Description -----------------------------------------------------
The Super Global Variable $_FILES is used in PHP 4.x.x.
$_FILES['upload']['size'] ==> Get the Size of the File in Bytes.
$_FILES['upload']['tmp_name'] ==> Returns the Temporary Name of the File.
$_FILES['upload']['name'] ==> Returns the Actual Name of the File.
$_FILES['upload']['type'] ==> Returns the Type of the File.

So if I uploaded the file 'test.doc', the $_FILES['upload']['name']
would be 'phptut.doc' and $_FILES['upload']['type'] would be 'application/msword'.
---------------------------------------------------------------------*/

//**********************************************************************//
//  $_FILES['filetoupload']  is the value of                            //
// file field from the form. <input type="file" name="filetoupload">    //
//**********************************************************************//

// this is the upload dir where files will go.
//Don't remove the /
//Chmod it (777)
$upload_dir = "../resimler/";   //change to whatever you want.
// files less than 1MB
$size_bytes = 1048576; //bytes  will be uploaded
$limit_file_type = "yes"; //Do you want to limit the types of files uploaded. (yes/no)
// specify file types.
$allowed_file_type = array('image/gif',
                           'image/pjpeg',
                           'image/jpeg',
                           'image/png',
                           'image/jpg');

          //check if the directory exists or not.
          if (!is_dir("$upload_dir")) {
	     die ("The directory <b>($upload_dir)</b> doesn't exist");
          }
          //check if the directory is writable.
          if (!is_writeable("$upload_dir")){
             die ("Klasore islem yapilmiyor <b>($upload_dir)</b> Kontrol ediniz, Modunu Chmod (777)");
          }

//Check first if a file has been selected
//is_uploaded_file('filename') returns true if
//a file was uploaded via HTTP POST. Returns false otherwise.
if (is_uploaded_file($_FILES['filetoupload']['tmp_name']))
{//begin of is_uploaded_file

         //Get the Size of the File
         $size = $_FILES['filetoupload']['size'];
         //Make sure that $size is less than 1MB (1000000 bytes)
         if ($size > $size_bytes)
         {
             echo "Dosya boyutu büyük.En fazla  <b>$size_bytes</b> bytes büyüklükte dosya yükleyebilirsiniz.";
             exit();
         }
              //checks file type
         if (($limit_file_type == "yes") && (!in_array($_FILES['filetoupload']['type'],$allowed_file_type)))
         {
             echo"Bu dosya uzantisi kabul edilmiyor";
             exit();
         }

         // $filename will hold the value of the file name submetted from the form.
         $filename =  $_FILES['filetoupload']['name'];
         // Check if file is Already EXISTS.
         if(file_exists($upload_dir.$filename)){
             echo "Lütfen dosya ismini degistiriniz <b>$filename </b> Baska dosya ismi yaziniz";
             exit();
         }

         //Move the File to the Directory of your choice
         //move_uploaded_file('filename','destination') Moves afile to a new location.
         if (move_uploaded_file($_FILES['filetoupload']['tmp_name'],$upload_dir.$filename)) {

            //tell the user that the file has been uploaded and make him alink.
            echo "Dosya (<a target='_blank' href=$upload_dir$filename>$filename</a>) Yüklendi!";
?>			
<br>
<form>
	<!--webbot bot="SaveResults" U-File="fpweb:///_private/form_results.csv" S-Format="TEXT/CSV" S-Label-Fields="TRUE" -->
	<p><input type="radio" value="dosya" name="dosya" onClick="window.opener.document.Kayit.resim.value='<?php echo $filename; ?>';self.close();"> 
	Resim Dosyası (Yazinin Altında) </p>
  <p>
    <input type="button" name="Button" value="tamam" onClick="window.opener.document.Kayit.resim.value='<?php echo $filename; ?>';self.close();">
    <?php
            exit();

         }
         else
         {
             //Print error
             echo "There was a problem moving your file";
             exit();
         }
}//end of is_uploaded_file


/*______________________________________________________________________________*/
///////////////////////////   Here is the most interesting thing.
//////////////////////////    it views the directory contents.....i'll disscuss next version.
/*
echo "<br><br><hr><br><b>Current Uploaded Files:</b><br>";

$rep=opendir($upload_dir);  // '.' means current directory
while ($file = readdir($rep)) {
	if($file != '..' && $file !='.' && $file !=''){
		if (!is_dir($file)){
			echo "    ";
                        echo "<a href=\"$upload_dir$file\" target=_blank>- $file</a>";
			echo "<br>";
		}
	}
}
closedir($rep);
clearstatcache();

              //END

*/

?>
</p>
</form>
	</body>
</html>
 

KaleSoft

0
İyinet Üyesi
Katılım
17 Kasım 2006
Mesajlar
170
Reaction score
0
600 olsun senni için ne zarari var?

yuklemeden sonra chmod(DOSYA,0775);
yap
 

s4l1h

0
İyinet Üyesi
Katılım
9 Şubat 2008
Mesajlar
20
Reaction score
0
Büyük ihtimal senin yüklediğin resimlerin owner leri nobody yada apache Olur ondan dolayı ftp den silmek istediğinde hata verir fakat dosyaları yazdığın bir script yardımıyla silebilirsin yada düzenleyebilirsin misal unlink("dosya.gif");

apache yi phpsuexec desteği ile derlersen Böyle bir sorun yaşamazsın
 

i.ari

0
İyinet Üyesi
Katılım
16 Aralık 2006
Mesajlar
4,437
Reaction score
6
Konum
Ankara
Arkadaşlar aynı script başka serverlarda kullanıyordum onlarda sorun cıkmıyordu. Bunda neden cıktı anlamadım.
Ftp de hiç bir işlem yapamıyorum. Buda baya kötü oldu. Bunu script üzerinde çözme şansım nedir. Her defasında manuel olarak chmod ayarlarını elimle mi yapmam gerekiyor?
 

Angelo

0
İyinet Üyesi
Katılım
13 Aralık 2004
Mesajlar
9,603
Reaction score
111
Konum
AZ
Ya chmod yapacaksın yüklemeden sonra, ya da suexec. Başka bir yolu yok. (ftp ye nobody olarak bağlatabilirsin ama cpanel filan kullandığını varsayarak bunu dikkate almıyoruz)
 

Türkiye’nin ilk webmaster forum sitesi iyinet.com'da forum üyeleri tarafından yapılan tüm paylaşımlardan; Türk Ceza Kanunu’nun 20. Maddesinin, 5651 Sayılı Kanununun 4. maddesinin 2. fıkrasına göre, paylaşım yapan üyeler sorumludur.

Üst