mtb211 Posted December 17, 2008 Share Posted December 17, 2008 if (!copy('kunden/muster/index.php', $dir.'/index.php')) { echo ("failed to copy $file...<br>\n"); } ive looked at different snippets but this code isnt working.. any idea? Quote Link to comment https://forums.phpfreaks.com/topic/137377-something-wrong-with-my-copy-command/ Share on other sites More sharing options...
premiso Posted December 17, 2008 Share Posted December 17, 2008 What is the error you are getting? If you are not getting an error put these at the top of the script: error_reporting(E_ALL); ini_set("display_errors", 1); Report back the error if there is one. Quote Link to comment https://forums.phpfreaks.com/topic/137377-something-wrong-with-my-copy-command/#findComment-717773 Share on other sites More sharing options...
mtb211 Posted December 17, 2008 Author Share Posted December 17, 2008 here is my error Warning: mkdir(qwa): File exists in /var/www/vhosts/punktewolke.de/httpdocs/kunden/erstell.php on line 20 Warning: copy(kunden/$dir/index.php): failed to open stream: No such file or directory in /var/www/vhosts/punktewolke.de/httpdocs/kunden/erstell.php on line 55 failed to copy ... here is the code to the whole file, sorry I didnt post this earlier <html> <head> <title>Unbenanntes Dokument</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <?php $dir = $uname; $user = $_POST['user']; $pass = $_POST['pass']; // Aktuelles Verzeichnis ermitteln $thisdir = str_replace(strrchr($_SERVER['SCRIPT_FILENAME'],'/'), '', $_SERVER['SCRIPT_FILENAME']); // Gewünschtes Verzeichnis erstellen $oldumask = umask(0); mkdir($dir,0777); umask($oldumask); // Daten für .htaccess erstellen $htaccess = 'AuthType Basic AuthUserFile '.$thisdir.'/'.$dir.'/.htpasswd AuthName "Enter user name and password please!" order deny,allow allow from all require valid-user'; // Daten für .htpasswd erstellen $htpasswd = $uname.':'.crypt($pw, substr(md5(uniqid(rand())), 0, 2)); // Testdatei erstellen (wird angezeigt beim erfolgreichen Login) /* $handle = fopen($dir.'/index.php', 'w'); fwrite($handle, ' <? echo "Hier sind die Bereitgestellten Dateien<br><br>"; $action=opendir("./"); while($datei=readdir($action)){ if(!preg_match("!(\.|\..)$!", $datei)){ if ($datei!="index.php" && $datei!=".htaccess" && $datei!=".htpasswd" ) { echo " <a href=\"$datei\"> $datei</a><br>"; } } } ?>'); fclose($handle); // .htaccess erstellen $handle = fopen($dir.'/.htaccess', 'w'); fwrite($handle, $htaccess); fclose($handle); */ if (!copy('kunden/muster/index.php', $dir.'/index.php')) { echo ("failed to copy $file...<br>\n"); } // .htpasswd erstellen $handle = fopen($dir.'/.htpasswd', 'w'); fwrite($handle, $htpasswd); fclose($handle); ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/137377-something-wrong-with-my-copy-command/#findComment-717774 Share on other sites More sharing options...
premiso Posted December 17, 2008 Share Posted December 17, 2008 Where is $uname defined? I do not see it anywhere? The basic gist of the copy error is that there is no file there. Try using the full path like this: if (!copy($_SERVER['DOCUMENT_ROOT'] . '/kunden/muster/index.php', $_SERVER['DOCUMENT_ROOT'] . '/' . $dir.'/index.php')) { echo ("failed to copy $file...<br>\n"); } That should put you in the right directory. Quote Link to comment https://forums.phpfreaks.com/topic/137377-something-wrong-with-my-copy-command/#findComment-717796 Share on other sites More sharing options...
mtb211 Posted December 17, 2008 Author Share Posted December 17, 2008 ahhh it did not work either hmm.. got the same exact error basically erstell is locted in website/kunden and the other directory is website/kunden/muster actually ftp would be website/httpdocs/kunden Quote Link to comment https://forums.phpfreaks.com/topic/137377-something-wrong-with-my-copy-command/#findComment-717808 Share on other sites More sharing options...
mtb211 Posted December 17, 2008 Author Share Posted December 17, 2008 thx for the help I guess its one little syntax problem somewhere anyone else has an idea it would be great matt Quote Link to comment https://forums.phpfreaks.com/topic/137377-something-wrong-with-my-copy-command/#findComment-717845 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.