Visualizzazione dei risultati da 1 a 3 su 3
  1. #1

    Cancella cartella dopo x tempo

    Buon pomeriggio a tutti, avrei un quesito da porvi.
    ho questo codice che funziona alla perfezione, tramite cronjob lo avvio e lui mi cancella tutti i file più vecchi di 7 giorni.
    Unico problema è che non mi cancella le cartelle, per il tipo di camera che ho acquistato non mi serve più che cancelli i file ma direttamente le cartelle all'interno di "public_html/******/cameracorridoio/cameracorridoio/"

    Sicuro di un vostro aiuto ne approfitto per augurarvi buon Ferragosto.


    <?

    // Define the folder to clean
    // (keep trailing slashes)
    $captchaFolder = 'public_html/******/cameracorridoio/cameracorridoio/';

    // Filetypes to check (you can also use *.*)
    $fileTypes = '*.*';

    // Here you can define after how many
    // minutes the files should get deleted
    $expire_time = 10080;

    // Find all files of the given file type
    foreach (glob($captchaFolder . $fileTypes) as $Filename) {

    // Read file creation time
    $FileCreationTime = filectime($Filename);

    // Calculate file age in seconds
    $FileAge = time() - $FileCreationTime;

    // Is the file older than the given time span?
    if ($FileAge > ($expire_time * 60)){

    // Now do something with the olders files...

    print "The file $Filename is older than $expire_time minutes\n";

    // For example deleting files:
    unlink($Filename);
    }

    }


    ?>

  2. #2
    Utente di HTML.it L'avatar di brodik
    Registrato dal
    Jan 2009
    Messaggi
    764
    http://php.net/manual/en/function.rmdir.php

    codice:
    Attempts to remove the directory named by dirname. The directory must be empty, and the relevant permissions must permit this.
    eXvision

  3. #3
    Quote Originariamente inviata da brodik Visualizza il messaggio
    http://php.net/manual/en/function.rmdir.php

    codice:
    Attempts to remove the directory named by dirname. The directory must be empty, and the relevant permissions must permit this.

    La directory non è vuota. Contiene file .jpg

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.