en l'occurence ce "fonctions/voir.php" n'existe pas. Ce que je voudrai
savoir c si il existe une fonction capable de me créer à la fois le
dossier et le fichier.
Jusqu'a aujourd'hui je faisais :
system('echo \'machaine\' > ' . $fichier );
tout aller bien car tous mes dossiers étaient créés mais maintenant je
suis obligé d'ajouter de nouvo dossier et donc je voudrai une création
automatique.
Est ce que c possible de passer autrement que par une boucle while qui
prend caractère par caractère jusqu'a un '/' pour ensuite vérifier si
le dossier existe, si ce n'est pas le cas (mkdir) sinon je continue ma
boucle ...
Je suis sur qu'il doit exister un truc de ce genre. :)
Donc en fait, pour bien créer le fichier comme il faut faire :
<?php
function RecursiveMkdir($path)
{
// This function creates the specified directory using mkdir(). Note
// that the recursive feature on mkdir() is broken with PHP 5.0.4 for
// Windows, so I have to do the recursion myself.
if (!file_exists($path))
{
// The directory doesn't exist. Recurse, passing in the parent
// directory so that it gets created.
RecursiveMkdir(dirname($path));
mkdir($path, 0777);
}
}
$fichier =
"/path/to/my/file";
if (!file_exists($fichier))
{
// Call the recursive mkdir function since the "recursive" feature
// built in to mkdir() is broken.
RecursiveMkdir(d
irname(
$fichier
));
// Vu que je suis sous linux je peux faire ça:
System('touch '.
Merci pour l'info, je pense avoir trouvé ce qu'il me fallait :) !
<?php
function RecursiveMkdir($path)
{
// This function creates the specified directory using mkdir(). Note
// that the recursive feature on mkdir() is broken with PHP 5.0.4 for
// Windows, so I have to do the recursion myself.
if (!file_exists($path))
{
// The directory doesn't exist. Recurse, passing in the parent
// directory so that it gets created.
RecursiveMkdir(dirname($path));
mkdir($path, 0777);
}
}
if (!file_exists("/path/to/my/file"))
{
// Call the recursive mkdir function since the "recursive" feature
// built in to mkdir() is broken.
RecursiveMkdir("/path/to/my/file");
}
?>
Je testerai ça ce soir