Einzelnen Beitrag anzeigen

Angel4585

Registriert seit: 4. Okt 2005
Ort: i.d.N.v. Freiburg im Breisgau
2.199 Beiträge
 
Delphi 2010 Professional
 
#13

Re: [PHP] Datei mit unlink löschen

  Alt 7. Okt 2009, 07:01
Lies dir hier vielleicht mal die Diskussion zu unlik durch: http://de3.php.net/manual/de/function.unlink.php

Speziell dieser Kommentar hier ist mir ins Auge gefallen:

Zitat:
I have founda that trying to delete a file using relative path like the example below does not work.

<?php
$do = unlink("../pics/$fileToDel");
if($do=="1"){
echo "The file was deleted successfully.";
} else { echo "There was an error trying to delete the file."; }
?>

I did not work at all, instead what I had to do was:

<?php
chdir('../pics/');
$do = unlink($fileToDel);
if($do=="1"){
echo "The file was deleted successfully.";
} else { echo "There was an error trying to delete the file."; }
?>

Then it worked !
Dazu noch dieser Ausschnit aus nem andern Kommentar:
Code:
<?php
    $old = getcwd(); // Save the current directory
    chdir($path_to_file);
    unlink($filename);
    chdir($old); // Restore the old working directory  
?>
Martin Weber
Ich bin ein Rüsselmops
  Mit Zitat antworten Zitat