Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]Relatywne ścieżki dla unlink
dembo
post
Post #1





Grupa: Zarejestrowani
Postów: 15
Pomógł: 0
Dołączył: 15.11.2007

Ostrzeżenie: (0%)
-----


Witam,
[PHP] pobierz, plaintext
  1. function serwer_usun_foto($serwer_usun_foto)
  2. {
  3. $katalog = '../../userfiles/image/';
  4. $i=0;
  5. while(isset($serwer_usun_foto[$i]))
  6. {
  7. if(file_exists($katalog.$serwer_usun_foto[$i])) echo "ISTNIEJE ";
  8. unlink($katalog.$serwer_usun_foto[$i]);
  9. echo "<img src=\"".$katalog.$serwer_usun_foto[$i]."\">";
  10. $i++;
  11. }
  12. }
[PHP] pobierz, plaintext

obrazek jest wyświetlany, natomiast file_exists dostaje FALSE, a unlink wyrzuca błąd nieistnienia pliku. Dlaczego ?

Ten post edytował dembo 21.09.2009, 22:00:58
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
dembo
post
Post #2





Grupa: Zarejestrowani
Postów: 15
Pomógł: 0
Dołączył: 15.11.2007

Ostrzeżenie: (0%)
-----


Nie jest ok, spotkałem się z problemem relatywnych ścieżek w necie. Nawet w manualu gość opisuje ten problem i daje jakieś tam rozwiązanie:
  1. $do = unlink("../pics/$fileToDel");
  2. if($do=="1"){
  3. echo "The file was deleted successfully.";
  4. } else { echo "There was an error trying to delete the file."; }
  5.  


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

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

,ale u mnie jakimś cudem ono nie działa.
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 27.12.2025 - 12:22