Page 1 of 1
php copy command not working
Posted: Fri Dec 19, 2008 2:28 am
by mtb211
Here is the error im receiving and below I posted the code for line 55
Warning: mkdir(qwa): File exists in /var/www/vhosts/punktewolke.de/httpdocs/kunden/erstell.php on line 20
Warning: copy(/var/www/vhosts/punktewolke.de/httpdocs/qwa/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 ...
Code: Select all
if (!copy($_SERVER['DOCUMENT_ROOT'] . '/kunden/muster/index.php', $_SERVER['DOCUMENT_ROOT'] . '/' . $dir.'/index.php')) {
echo ("failed to copy $file...<br>\n");
}
ive edited this code like crazy but im still receiving the same error, any ideas?
Matt

Re: php copy command not working
Posted: Fri Dec 19, 2008 2:36 am
by pcoder
Are you sure the file is in the appropriate location?
Re: php copy command not working
Posted: Fri Dec 19, 2008 2:38 am
by mtb211
hey coder, i sent a screen shot (just a minute ago.. I modified my post .. I put [copy] instead of
Code: Select all
.. )
I believe its in the correct place, i could be making a huge novice error
thanks for the help!
Re: php copy command not working
Posted: Fri Dec 19, 2008 3:09 am
by pcoder
An another likely cause is the file permission.Check out the file permission. Permission lower than 644 may be problematic.
Re: php copy command not working
Posted: Fri Dec 19, 2008 3:13 am
by mtb211
it was on 644 and now I changed it to 777... still have an error
hmm..
Re: php copy command not working
Posted: Fri Dec 19, 2008 4:24 am
by pcoder
Code: Select all
$_SERVER['DOCUMENT_ROOT'] . '/' . $dir.'/index.php'
In this destination location, where does this $dir comes from. Please be sure with the upper/lower case also.
Re: php copy command not working
Posted: Fri Dec 19, 2008 5:32 am
by mtb211
Hey coder,
thanks for helping me out
Are you talking about where I declare?
Code: Select all
<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($_SERVER['DOCUMENT_ROOT'] . '/kunden/muster/index.php', $_SERVER['DOCUMENT_ROOT'] . '/' . $dir.'/index.php')) {
echo ("failed to copy $file...<br>\n");
}
// .htpasswd erstellen
$handle = fopen($dir.'/.htpasswd', 'w');
fwrite($handle, $htpasswd);
fclose($handle);
?>
</body>
</html>
it looks like everything is okay

I hate syntax errors