Advanced Search

Page 1 of 3 123 LastLast
Results 1 to 10 of 30

Thread: copying image files from local server to remote server

  1. #1
    Join Date
    Sep 2009
    Posts
    24
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default copying image files from local server to remote server

    Hi,

    The local path for my file : C:\wamp\www\noyaevofis\images\bg.GIF

    The code : if (copy("C:\wamp\www\noyaevofis\images\bg.GIF", "bg.GIF")) { echo ("saved"); } else { echo ("not saved); }


    This code works in local server but gives the followig error in remote server :

    Warning: copy(C:\wamp\www\noyaevofis\images\bg.GIF) [function.copy]: failed to open stream: No such file or directory in ....


    This is a new problem because the above code worked in various remote servers since 2005 until July 2009.

    I assume that I'm missing an update.

    I'll appriciate your valuable hints.

    Nejat

  2. #2
    Join Date
    Apr 2008
    Location
    Limoges, France
    Posts
    395
    Thanks
    13
    Thanked 61 Times in 61 Posts

    Default

    Your remote server's path to the file is C:\wamp\www\noyaevofis\images\bg.GIF ? If not, that is your problem. Try logging into the remote server with an FTP client and looking for the file. Once you find it, you'll be able to see exactly what the path is.

  3. #3
    Join Date
    Sep 2009
    Posts
    24
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default

    Thank you for your reply.

    The path in remote server is different.

    As I mentioned before this code always worked with different remote-server-paths in various remote servers since 2005 until July 2009. I never had a path problem for these past 4 years.

    The problem is that the remote server does not accept the source path as my local path anymore.

  4. #4
    Join Date
    Apr 2008
    Location
    Limoges, France
    Posts
    395
    Thanks
    13
    Thanked 61 Times in 61 Posts

    Default

    All I can tell you is that the path to the file you want to copy is not correct on your remote server.

    When you say remote server, are you talking about a server on the web? Or a server on you local network?

  5. #5
    Join Date
    Sep 2009
    Posts
    24
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default

    Remote Server is on the web, Local Server is on my computer.

  6. #6
    Join Date
    Apr 2008
    Location
    Limoges, France
    Posts
    395
    Thanks
    13
    Thanked 61 Times in 61 Posts

    Default

    Well it is unlikely that your web server is using WAMP.

    Thus, the directory structure on your web server is different than your local server. This means the paths to the files are different. You must know the path to the file you wish to copy and use that path when calling copy.

  7. The Following User Says Thank You to JasonDFR For This Useful Post:

    psikolog (09-02-2009)

  8. #7
    Join Date
    Sep 2009
    Posts
    24
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default

    Thank you for giving your valuable time to me.

  9. #8
    Join Date
    Sep 2009
    Posts
    24
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default

    Maybe the following code will make the issue more clear.

    The target directory "/logo" is on the remote server hosted on web and it contains a lot of files and its chmod is 777.

    <?php

    if (!isset($_REQUEST['logoAdres'])) {$logoAdres="";} else $logoAdres = $_REQUEST['logoAdres'] ;
    if (!isset($_REQUEST['PLogo'])) {$PLogo="";} else $PLogoAdres = $_REQUEST['PLogo'] ;
    if (!isset($_REQUEST['Pname'])) {$Pname="";} else $Pname = $_REQUEST['PnameAdres'] ;

    ?>

    <form name="Fedit" method="post" enctype="multipart/form-data">

    <table align="center" width="600" cellspacing="2" cellpadding="2" style="border:1px outset #ECECEC;">
    <tr>
    <td bordercolor="#ececec" >Logo : </td>
    <td bordercolor="#ececec">
    <input type="file" name="PLogo" size="70" style="font:7pt verdana;color:#003399" onchange="document.Fedit.logoAdres.value=this.value;">
    <input type="hidden" name="logoAdres">
    </td>
    </tr>
    <tr>
    <td bordercolor="#ececec" >Name for Logo : </td>
    <td bordercolor="#ececec"><input type="text" name="Pname" size="50" maxlength="255" style="font:7pt verdana;color:#003399"></td>
    </tr>
    <tr>
    <td bordercolor="#ececec" align="center" colspan="2">
    <input type="submit" name="action" value="Save" onmouseover="this.style.cursor='pointer';">
    </td>
    </tr>
    </table>

    </form>

    <?

    $action = strtolower(trim($action));

    switch($action)
    { case "save" : action_update($PLogo,$Pname,$logoAdres); break; }


    function action_update($PLogo,$Pname,$logoAdres)
    {
    if ($logoAdres !== "") {$PLogo = $logoAdres ;}

    if ($PLogo !=="" )
    {
    chdir("./logo");
    if (copy($PLogo, $Pname)) { echo ("$PLogo saved"); } else { echo ("$PLogo is not saved"); }
    chdir("..");
    }
    }
    ?>

  10. #9
    Join Date
    Sep 2009
    Posts
    24
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default

    I tested this code on Yahoo server and it worked, no errors occured and every file I selected via the form from my computer (local) has been saved to the related directory on Yahoo (remote) server.

    Now the conclusion :

    Yahoo server's PHP Version is 4.3.11 | My remote server's PHP Version is 5.2.9

    Interpretation of copy() function has been changed in 5.2.9.

    Nejat

  11. #10
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,627
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    Quote Originally Posted by php5 changelog
    (here)
    5.3.0 Added context parameter for copy() function. (Sara)
    All I could find. It would cause some change in functionality, but I don't think it's the cause of your problem. In fact, if you used to be able to use the code successfully with the wrong path, I would say that that was a problem with your server/setup.
    We Only Torture the Folks We Don't Like (You're Probably Gonna Be Okay)
    It's a Party in the CIA

Bookmarks

Posting Permissions

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