[solved]how to make file copy in php
Posted: Mon Jul 30, 2007 11:36 am
Hi
I have tried so many times to work it out. But i am unable to do it.
I have tried to copy a file from one directory to another directory but its working in my local computer but after uploading this to the godaddy server its not working for me.
Code given below.
Please let me know if anybody has come across this problem and got the solution.
Thank you very much.
I have tried so many times to work it out. But i am unable to do it.
I have tried to copy a file from one directory to another directory but its working in my local computer but after uploading this to the godaddy server its not working for me.
Code given below.
Code: Select all
if($work=="add_site")
{
$short = $_POST['short_name'];
if(mkdir("../$short/", 0777))
{
$file = "../includes/index.php";
$newfile = "../$short/index.php";
if(copy($file, $newfile)=='1'){
$str = "insert into table_site(short_name,display_name,tot_lines,block) values('".$_POST['short_name']."','".$_POST['display_name']."','".$_POST['tot_lines']."',0)";
$str = mysql_query($str);
if(mysql_affected_rows()>=1)
{
$_SESSION['msg'] = "Successfully site added";
header("Location:admin_sites.php");
}
}
else
{
$_SESSION['msg'] = "Failed to copy file";
header("Location:add_site.php");
}
}
}Thank you very much.