yüksek dizindeki dosyaları silerek

0 Cevap php

im yüksek dizinden bir dosya silme sorunlarınız, ben bu yazı bulundu ve o .... ama hayır şans denedi:

gotdalife at gmail dot com 25-Sep-2008 02:04

To anyone who's had a problem with the permissions denied error, it's sometimes caused when you try to delete a file that's in a folder higher in the hierarchy to your working directory (i.e. when trying to delete a path that starts with "../").

So to work around this problem, you can use chdir() to change the working directory to the folder where the file you want to unlink is located.

<?php
>     $old = getcwd(); // Save the current directory
>     chdir($path_to_file);
>     unlink($filename);
>     chdir($old); // Restore the old working directory     ?>

burada ben şu anda sahip kodu:

session_start();

if (!isset($_SESSION['agent']) OR ($_SESSION['agent'] !=md5($_SERVER['HTTP_USER_AGENT']))){

    require_once ('includes/login_functions.inc.php');
    $url = absolute_url();
    header("Location: $url");
    exit();
}  



$folder = $_GET['folder'];
$filename = $_GET['name'];
$path = "../gallery/photos/$folder";

if (isset($_POST['submitted'])) {

    if ($_POST['sure'] == 'Yes') {  

        $old = getcwd(); // Save the current directory
        chdir($path);
        unlink($filename);
        chdir($old); // Restore the old working directory  

    }
    else{

        echo '<p>The photo has NOT been deleted.</p>';
    }
}

Ben hata mesajı alıyorum:

Warning: unlink() [function.unlink]: No error in J:\xampp\htdocs\bunker\admin\delete_file.php on line 37

satır 37 olmak:

unlink($filename);

Herkes yanlış yaptığımı görebiliyorum?

Zaman ayırdığınız için teşekkür ederim.

0 Cevap