cristian77 Posted January 21, 2019 Report Share Posted January 21, 2019 Salut, Am nevoie de putin ajutor in codul de mai jos. Vreau sa citesc continutul unui fisier si sa il copiez intr-un fisier creat nou dintr-un random directory: <?php error_reporting(E_ALL); $dirname = uniqid(); mkdir($dirname); $newFileName = '/'.$dirname.'/newfile.txt'; $newFileContent = 'someinfofile.txt'; if (file_put_contents($newFileName, $newFileContent) !== false) { echo "File created (" . basename($newFileName) . ")"; } else { echo "Cannot create file (" . basename($newFileName) . ")"; } ?> Primesc eroare ca nu exista fisierul in directorul respectiv.. Quote Link to comment Share on other sites More sharing options...
cristian77 Posted January 21, 2019 Author Report Share Posted January 21, 2019 16 minutes ago, cristian77 said: sier Daca folosesc linia $newFileName = $dirname.'/newfile.txt'; Primesc eroare: Notice: Undefined variable: dirname in C:\xampp\htdocs\test1.php on line 6 Am incercat deasemenea varianta de mai jos aceeasi poveste: <? $dirname = uniqid(); mkdir($dirname); copy('contentfile.txt', '/'.$dirname.'/newfile.txt'); ?> Quote Link to comment Share on other sites More sharing options...
cristian77 Posted January 21, 2019 Author Report Share Posted January 21, 2019 (edited) Functioneaza, multumesc frumos! problema este ca orice as pune in continuare spre exemplu echo('done'); Imi da asa: Parse error: syntax error, unexpected 'echo' (T_ECHO) in C:\xampp\htdocs\test.php on line 6 Iar codul simplu pus in test.php vine cu eroarea: Notice: Use of undefined constant - assumed ' ' in C:\xampp\htdocs\test.php on line 6 Cu toate ca el lucreaza. Edited January 21, 2019 by cristian77 Quote Link to comment Share on other sites More sharing options...
cristian77 Posted January 21, 2019 Author Report Share Posted January 21, 2019 <? $dirname = uniqid(); mkdir($dirname); copy('matrice.txt', $dirname.'/newfile.txt'); echo('done'); ?> Am rezolvat, functioneaza! Multumesc. Quote Link to comment Share on other sites More sharing options...
Wav3 Posted January 21, 2019 Report Share Posted January 21, 2019 Invata sa citesti erorile pentru ca iti spun mura-n gura unde este problema. Quote Link to comment Share on other sites More sharing options...
BogdanWDK Posted January 21, 2019 Report Share Posted January 21, 2019 2 hours ago, cristian77 said: <? $dirname = uniqid(); mkdir($dirname); copy('matrice.txt', $dirname.'/newfile.txt'); echo('done'); ?> Am rezolvat, functioneaza! Multumesc. echo "done"; 2 Quote Link to comment Share on other sites More sharing options...