Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jun 2005
    Posts
    91
    Thanks
    19
    Thanked 0 Times in 0 Posts

    file cpoy problem...

    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.

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    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().


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •