copy file with a specific begining like 'thumb_' php copy file with a specific begining like 'thumb_' php
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

copy file with a specific begining like 'thumb_' php

Started by nasirmulani, September 02, 2007, 10:33:57 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

nasirmulani

could some help in writing a php code for copying specific files that start with 'thumb_' only and no other file. like we copy files with specific extension i want to copy files with specific starting. guys please help.

this is the code i am using but its not reading the content of the folder, it does  not read the file in a folder, i want to implement it for subdirs also.


<html><body>

<form action="copy.php" method="GET">
Source: <input type="text" name="source" />
Dest: <input type="text" name="dest" />
<input type="submit" />
</form>
</body></html>
<?php

function full_copy$source$target )
    {
        if ( 
is_dir$source ) )
        {
           @
mkdir$target );
           echo 
"<b>Creating dir:</b>".$target." <br/>";
            
$d dir$source );
           
            while ( 
FALSE !== ( $entry $d->read() ) )
            {
                if ( 
$entry == '.' || $entry == '..' )
                {
                    continue;
                }
               
                
$Entry $source '/' $entry;           
                if ( 
is_dir$Entry ) )
                {
                  
full_copy$Entry$target '/' $entry );
                  echo 
"<b>Copying file: </b> ".$target '/' $entry ."<br />" ;
                  continue;
                }

foreach (
glob("thumb_*") as $filename) {
    if (
copy($Entry.'/'.$filename,$target '/' $entry .'/'.$filename)) {
      echo 
"$filename copied to thumbs/$filename<br />";
    } else {
      echo 
"Unamble to copy $filename to thumbs/$filename<br />";
    }
  }
                  }
           
            
$d->close();
        }else
        {
  foreach (
glob("thumb_*") as $filename) {
    if (
copy($source.'/'.$filename,$target '/'.$filename)) {
      echo 
"$filename copied to thumbs/$filename<br />";
    } else {
      echo 
"Unamble to copy $filename to thumbs/$filename<br />";
    }
  }


        }

}

//*****************************

if (isset($_GET["source"]) && isset($_GET["dest"]))
{
$sr$_GET["source"];
$ds$_GET["dest"];
} else
{
$sr"";
$ds"";

}
if (!
$sr == "" && !$ds == "") {
echo 
full_copy($sr$ds);
}


?>



Joachim Müller

Starting a thread related to coppermine on a board that deals with photography only is not a bright idea, especially if you want others to look into your issues. In the future, be more carefull when starting new threads and respect board rules.

nasirmulani

yes i do know that and let me tell u that i am developing this code for my photo gallery for which i use coppermine gallery. I am developing this code so that i can copy only the thumbnails to a different directory and enable them to be hotlinked and use them in forums in bbcode. I have disabled hot linking to full size image to save bandwidth.

thanks for such a rude reply, i wont be using this shittty forum of yours any more.

Joachim Müller

Thanks for your enlightening response. It's always a pleasure to hear such gentle words. I will gladly do as you suggest and add you to a special user group that exists for nice folks like you. The group's name is "banned users". Bye.