View Full Version : file cpoy problem...

07-03-2005, 02:29 PM
I want to copy files to other directory with encrypted prefix.

files: a_B.jpg, b_C.gif, c_F.jpg, d_G.gif, aa_g.wmv, cd_1_W.wmv, e_K.jpg, d_T_f.gif, f_S_D_f.wmv
$src_path = /test/test1
$dst_path = /test/test2/test_files

for ($i=0;$i <= sizeof($files)-1; $i++){
$file1 = substr(md5($i),0,8) . "_" . $row[files];
$file1_source = $row[files];
if (copy("$src_path/$row[files]", "$dst_path/$file1")) {
print ("copied *$dst_path/$file1"); } else { print ("failed copy $dst_path/$file1");

Problem 1: some files copied, but some files shows error
copy failed to open stream: No such file or directory,
copy failed to open stream: Permission denied

Problem 2: some files were copied by upper_letters.
a_B.gif to A_B.gif

What am I missing?

Any comment would be appreciated.

07-03-2005, 03:55 PM
Possible problems:
$row doesn't exist.
$files doesn't exist.
Due to no $row, neither $file1 or $file1_source exists (correctly).

I don't understand problem #2.

Also see: rename().