Jump to content

copy Folder files and SubFolder


p9j

Recommended Posts

hi all,

 

i have this music website and i have to upload every album under this folder "newsongs" ... in AlbumName folder i have normal quilty songs and HQ folder..under HQ folder i have High Quilty songs for each album.

 

 

i have this coding which moves Album folder  and normal quilty songs to other folder "songs" but i also want to move subfolder "HQ" and High Quilty songs with AlbumName  folder

 

 

 

for($i=0;$i<=$ct;$i++)
{
$alb=$alname[$i];
$cat=$catname[$i];
$albids=$albid[$i];
$fon=$folder_name[$i];

$tmp_name=$doc_root."newsongs/$fon";
$uploads_dir=$doc_root."songs/$cat/$fon";

if ($handle = opendir($tmp_name)) {
	/* This is the correct way to loop over the directory. */ 
	while (false !== ($file = readdir($handle))) {
		//echo "$file\n <br>";
		if($file !=='..' and $file !=='.')
		{
		$song_path="songs/$cat/$fon/$file";
			if(!is_dir("$tmp_name/$file") and (!is_dir("$uploads_dir/$file")))
			{
				if(copy("$tmp_name/$file", "$uploads_dir/$file"))
				{
				$cp=1;
				$ext=substr($file,-4);
					if($ext=='.mp3')
					$insqry=mysql_query(" insert into tbl_songs set song_name='$file', album_id='$albids', artist_id='$artid', song_path='$song_path' ");

				unlink($tmp_name.'/'.$file);
				}
				else
				{
				echo "could not move songs ";
				}
			}
		}
			if($insqry)
			  $msg="songs Added to the database";
			else
			$msg="songs Not Added to the database";
	}
	closedir($handle);

 

thnx in advnce 8)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.