A Flash Developer Resource Site

Results 1 to 10 of 10

Thread: [RESOLVED] php copy fails

  1. #1
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449

    resolved [RESOLVED] php copy fails

    Hi,

    I want to copy a file into a folder in the same directory, but whatever I tried it doesn't work. Here is an example script.

    $curdir = opendir($folder);
    $source_file = "test.txt";
    $destination_file = "/" . $folder . "/" . $source_file;
    copy($source_file, $destination_file);
    closedir($curdir);

    I get for example error messages like this:
    PHP Warning: copy(/Joachim/test.txt): failed to open stream: Operation not permitted in /home/flashs46/public_html/test/iamanactor/createfile.php on line 51

    I am just following other's example code, however without success.

    I was wondering if it is possible to copy a folder with contents and give it a new name. That would solve my problem as well.
    - The right of the People to create Flash movies shall not be infringed. -

  2. #2
    Registered User
    Join Date
    Feb 2001
    Posts
    13,041
    Hi,

    are you sure you want to place files near the root /

    Musicman

  3. #3
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    No, I want to place a file into a subfolder. But i learnt about open_basedir restriction. As I understand the host does not allow to move files into a subfolder. Correct me if I am wrong. Is there a bypass?

    I am also getting this message:

    SAFE MODE Restriction in effect. The script whose uid/gid is 32131/632 is not allowed to access
    - The right of the People to create Flash movies shall not be infringed. -

  4. #4
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    don't know if this will help. but this is the way i go at it-
    PHP Code:
    // in Flash
    lv = new LoadVars();
    lv.file = "copyswf.swf"; // this file is in folder - examples
    lv.newfile = "test.swf"; // copy file to folder - temp/test
    lv.ID = "test";

    lv.onLoad = function(){
    trace(unescape(this));
    }
    lv.sendAndLoad("http://www.domain/examples/copyswf.php",lv,"POST");

    /*--copyswf.php--

    <?php
    $file 
    $_POST['file'];
    $newfile $_POST['newfile'];
    $ID $_POST['ID']; 

    $path "../temp/".$ID."/"
    if (!
    file_exists($path)) { 
        
    mkdir($path,0777); 
        
    chmod($path,0777); 



    if (!
    copy($file$path.$newfile)) {
       echo 
    "failed to copy";
    } else {
       echo 
    $file copied to $path$newfile";
    }
    ?> 

    */
    any help ??

  5. #5
    Registered User
    Join Date
    Feb 2001
    Posts
    13,041
    Hi,
    have a look at the filenames in the error message.There is /home/flashs46/public_html/test/iamanactor/createfile.php and /Joachim/test.txt
    So /home/flashs46/public_html is your web folder, test is a subfolder thereof, and joachim should be another subfolder. et rid of that / in front of the filename.
    Apart from that, make sure that the joachim folder has proper access rights - you will probably need a chmod 777 for it

    Musicman

  6. #6
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    Thanks a lot for both of your suggestions. I will try out
    - The right of the People to create Flash movies shall not be infringed. -

  7. #7
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    Ok,

    here is the problem I found out. If I create a folder by php with 0777 permissions and use this line:

    copy("test.txt","/home/flashs46/public_html/test/iamanactor/Test/test.txt");

    I get error message.

    If on the other hand I create the folder manually (I have fetch) then the file is nicely copied into the folder without errors. The server obviously distinguishes between folders created by php and manually.
    Last edited by cancerinform; 11-11-2007 at 04:26 PM.
    - The right of the People to create Flash movies shall not be infringed. -

  8. #8
    Registered User
    Join Date
    Feb 2001
    Posts
    13,041
    Hi,

    more likely, the mkdir with 0777 does not work but mkdir followed by chmod(0777) works

    Musicman

  9. #9
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    Yeah, I had that already before but it did not work. I confirmed the permissions were really 777 and they were. This is the error message I get:

    SAFE MODE Restriction in effect. The script whose uid/gid is 32131/632 is not allowed to access /home/flashs46/public_html/test/iamanactor/Test owned by uid/gid 99/99 in /home/flashs46/public_html/test/iamanactor/copyfile.php

    Again when I click on create folder in the Fetch menu, set permissions to 777 and test the copy script it works. So it is not because of permissions or because of scrypt syntax but because of the above reason (e-message), which I don't know how to address.

    This is what I found:

    http://bugs.php.net/bug.php?id=18500
    Last edited by cancerinform; 11-12-2007 at 11:27 AM.
    - The right of the People to create Flash movies shall not be infringed. -

  10. #10
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    The problem was the settings created by the hosting company. After I contacted them they resolved the problem and made the changes. Thanks for all the help
    - The right of the People to create Flash movies shall not be infringed. -

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center