copy() command doesnt work for file in other hosts

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • teo46
    New Member
    • Jul 2015
    • 3

    copy() command doesnt work for file in other hosts

    my code is :
    Code:
    <?php
    $file = "http://img2.hdfilmsitesi.com.tr/wp-content/uploads/2015/01/Oz-Efsanesi.jpg";
    $folder = "../thumbnails/asd.jpg";
    copy($file,$folder) or die("failed to copy ... ");
    ?>
    i checked permissions(777 ).When i try $file= in my hosting its working.
    Last edited by Rabbit; Jul 10 '15, 05:03 PM. Reason: Please use [code] and [/code] tags when posting code or formatted data.
  • Luuk
    Recognized Expert Top Contributor
    • Mar 2012
    • 1043

    #2
    It seems to work for me:
    Code:
    luuk@opensuse:~/tmp> cat copy.php
    <?php
        $file = "http://img2.hdfilmsitesi.com.tr/wp-content/uploads/2015/01/Oz-Efsanesi.jpg";
        $folder = "asd.jpg";
        copy($file,$folder) or die("failed to copy ... ");
    ?>
    
    
    luuk@opensuse:~/tmp> php copy.php
    
    
    luuk@opensuse:~/tmp> ls -l asd.jpg
    -rw-r--r-- 1 luuk users 68273 jul 11 09:44 asd.jpg
    luuk@opensuse:~/tmp>

    Comment

    • teo46
      New Member
      • Jul 2015
      • 3

      #3
      No its failed. İf i change "http://img2.hdfilmsite si.com.tr/wp-content/uploads/2015/01/Oz-Efsanesi.jpg" to "index.php" work fine.But i cant download any file from other hosts.

      Comment

      • Luuk
        Recognized Expert Top Contributor
        • Mar 2012
        • 1043

        #4
        What error do you have?

        Code:
        luuk@opensuse:~/tmp> chmod -w asd.jpg
        luuk@opensuse:~/tmp> php copy.php
        PHP Warning:  copy(asd.jpg): failed to open stream: Permission denied in /home/luuk/tmp/copy.php on line 4
        failed to copy ... luuk@opensuse:~/tmp>

        Comment

        • teo46
          New Member
          • Jul 2015
          • 3

          #5
          There is no error just failed . How can i see error code?(I tried
          Code:
          error_reporting(E_ALL);
          still no error code)

          Comment

          • Luuk
            Recognized Expert Top Contributor
            • Mar 2012
            • 1043

            #6
            it could be (not tested by me) a disabled function:


            did you also check the error_log?
            Code:
            [11-Jul-2015 12:08:01 CET] PHP Warning:  copy(asd.jpg): failed to open stream: Permission denied in /home/luuk/public_html/temp/copy.php on line 4

            Comment

            Working...