make folder and copy files in client local drive from server
Posted: Thu Oct 29, 2009 2:38 am
Hi All,
I'm using PHP thru WAMP server 2 for a project.
I have some MP3 files stored on the server. Now logged in at some other client machine, I want to copy some files from the server machine to client machine thru the copy($source,$destination) function. For this i have to define a particular drive on the client machine and make a user defined directory (that client inputs in a form) where the files will be coppied. Using the mkdir($dir) function i want to create the directory and copy the files over there.
The whole process is running absolutey fine on the server machine (i.e, if i log on at the server and perform the action), but it is not working on remote client machine since the mkdir function cannot create a folder in a remote client file system.
Can i use the client IPadress to create a directory in the remote client machine? Or there is some other way to do this? Please help because I'm stuck with this problem for a number of days.
P.S.: I do not want a save request download diolog box for individual files, nor a zipped file download. I just want to copy the specified files in a specific defined folder in client machine.
My Code:
$folder=$_GET['folder']; // user defined folder inputed from a form
$dir="D:\\".$folder."/"; // Destination Directory to copy the files
if(!is_dir($dir))
{
mkdir($dir);
chmod($dir,0777);
}
$sqlDownloadTracks=mysql_query("select filename from tbldownloadtracks where requestWishListid='$requestWishListid'");
$copiedtracks=0;
$totaltracks=0;
while($rowDownloadTracks=mysql_fetch_array($sqlDownloadTracks))
{
$filename=$rowDownloadTracks['filename'];
$file = "controlp/uploads/".$filename;
$newfile = $dir.$filename;
if (copy($file, $newfile))
{
chmod($newfile,0777);
$copiedtracks++;
}
$totaltracks++;
}
Thanks and Regards in advance.
I'm using PHP thru WAMP server 2 for a project.
I have some MP3 files stored on the server. Now logged in at some other client machine, I want to copy some files from the server machine to client machine thru the copy($source,$destination) function. For this i have to define a particular drive on the client machine and make a user defined directory (that client inputs in a form) where the files will be coppied. Using the mkdir($dir) function i want to create the directory and copy the files over there.
The whole process is running absolutey fine on the server machine (i.e, if i log on at the server and perform the action), but it is not working on remote client machine since the mkdir function cannot create a folder in a remote client file system.
Can i use the client IPadress to create a directory in the remote client machine? Or there is some other way to do this? Please help because I'm stuck with this problem for a number of days.
P.S.: I do not want a save request download diolog box for individual files, nor a zipped file download. I just want to copy the specified files in a specific defined folder in client machine.
My Code:
$folder=$_GET['folder']; // user defined folder inputed from a form
$dir="D:\\".$folder."/"; // Destination Directory to copy the files
if(!is_dir($dir))
{
mkdir($dir);
chmod($dir,0777);
}
$sqlDownloadTracks=mysql_query("select filename from tbldownloadtracks where requestWishListid='$requestWishListid'");
$copiedtracks=0;
$totaltracks=0;
while($rowDownloadTracks=mysql_fetch_array($sqlDownloadTracks))
{
$filename=$rowDownloadTracks['filename'];
$file = "controlp/uploads/".$filename;
$newfile = $dir.$filename;
if (copy($file, $newfile))
{
chmod($newfile,0777);
$copiedtracks++;
}
$totaltracks++;
}
Thanks and Regards in advance.