Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 30

Thread: copying image files from local server to remote server

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

    Default

    Thank you for your hint.

    I know php.net/copy declaration, but it doesn't give the answer I need.

    I still believe in that the problem occurs because of the interpretation of version 5.2.9-1.

    Here is my commitment :

    Before PHP Version 5.2.9 "the source file" could be placed on local computer or on remote server (on the web) or it could be URL on the web.

    The location of the source file doesn't make any difference if the server has the PHP Version older than 5.2.9. There will be no errors while uploading a file from the user's computer to the web server that the script is running on via a form enctyped as multipart/form-data.

    But in version 5.2.9 the source file can only be either a URL on the web or a path on remote server (on the web). Copy() function interprets the POSTed file path as a path on the server it is running on.

    I tested my script on 3 different environments :

    1. on my local server (on my computer) => it worked.

    2. on Yahoo server with version 4.3.11 => it worked.

    3. on another server with version 5.2.9-1 => it did not work.

    The job is simple :

    - there is a file on the desktop of the user.

    - user enters the page.

    - page has a form (enctype="multipart/form-data)

    - form has an input (type="file") element.

    - when the user clicks the submit button the full path of the file is POSTed

    - the action file runs copy() function.

    This simple job gives different results depending on the PHP Version.

    Let's wait and see.

    Thank you again.

    Nejat

  2. #12
    Join Date
    Mar 2007
    Location
    New York, NY
    Posts
    557
    Thanks
    8
    Thanked 66 Times in 66 Posts

    Default

    Is it possible that other differences exist? Did you set permissions correctly on the server? [CHMOD?]

    According to:
    http://us2.php.net/copy

    The ONLY changes in this function were in v.4.3.0 and v.5.3.0:

    5.3.0 => Added context support.
    4.3.0 => Both source and dest may now be URLs if the "fopen wrappers" have been enabled. See fopen() for more details.

    It's also possible that there's a server configuration problem in the server where the copy() isn;'t working - try contacting your host.
    - Josh

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

    Default

    If your problem is only with the copy() function I can tell you for sure that the version of php does not matter.

    Can you tell us what the path to the file you want to copy is on your remote(web) server. From what you have said, this is where the problem lies.

    It also seems like you are using relative paths. I would caution against this, as changes you make are more likely to cause things to break.

    You could for example define an APPLICATION_PATH, then base all your paths off of that. Or use the $_SERVER['DOCUMENT_ROOT'] variable so you always have an absolute path to work off of.

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

    Default

    Quote Originally Posted by JShor View Post
    Is it possible that other differences exist? Did you set permissions correctly on the server? [CHMOD?]
    He would be getting a Permission Denied error if that was the case.

  5. #15
    Join Date
    Mar 2007
    Location
    New York, NY
    Posts
    557
    Thanks
    8
    Thanked 66 Times in 66 Posts

    Default

    I don't think that's his problem. Seems more complex than something as simple as a misdirected path ...
    - Josh

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

    Default

    The directory structure on my local computer and remote server are identical.

    All the related directories have chmod 777.

    I have been using this remote server for more than a year and this problem occured after the server's php upgraded to ver 5.2.9.1

    Nothing has been changed except PHP version on recent remote server.

    I have been also using this script on Yahoo server for 3 years with a php version of 4.3.1.1 and this code works on that server perfectly well.

    This code also worked on another server between the years 2005 - early 2008 without any problem.

    I am sure that the problem is not because of the directory / path structure.

    When I posted this issue I was hoping that someone has idea about the interpretation of copy() function.

    Don't worry, I still have hope.

    Thank both of you and I'll be pleased hearing your new comments.

    Nejat

  7. #17
    Join Date
    Mar 2007
    Location
    New York, NY
    Posts
    557
    Thanks
    8
    Thanked 66 Times in 66 Posts

    Default

    No, he wouldn't be getting any errors except the one he stated, here:

    PHP Code:
    if ($PLogo !=="" )
    {
    chdir("./logo");
    if (
    copy($PLogo$Pname)) { echo ("$PLogo saved"); } else { echo ("$PLogo is not saved"); }
    chdir("..");
    }

    Any error he gets will say $PLogo is not saved. If there's an error, the IF boolean would return FALSE, and therefore the ELSE statement would take into effect.
    - Josh

  8. #18
    Join Date
    Mar 2007
    Location
    New York, NY
    Posts
    557
    Thanks
    8
    Thanked 66 Times in 66 Posts

    Default

    Quote Originally Posted by psikolog View Post
    I have been using this remote server for more than a year and this problem occured after the server's php upgraded to ver 5.2.9.1

    Nothing has been changed except PHP version on recent remote server.
    Hey, things happen, people make mistakes. What I'm thinking is most likely, is that whoever the server admin who upgraded the php version was, made some other crucial mistake where the file system isn't working as it should.

    Either that, or the php.ini file needs to be edited to accommodate files [which in retrospect, seems more likely in this case].

    Good luck.
    - Josh

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

    Default

    Is this the error message you are getting on your remote server?

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

    That is the error message you posted in your first post.

    Is your remote server running WAMP?
    Does this path exists on your remote server?
    If you upload a file to this path 'C:\wamp\www\noyaevofis\images\' on your remote server, then run this:
    PHP Code:
    copy('C:\wamp\www\noyaevofis\images\test.ext''C:\wamp\www\noyaevofis\images\test2.ext'); 
    (replace 'test.ext' with an actual file)

    What happens?

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

    Default

    Quote Originally Posted by JShor View Post
    Hey, things happen, people make mistakes. What I'm thinking is most likely, is that whoever the server admin who upgraded the php version was, made some other crucial mistake where the file system isn't working as it should.

    Either that, or the php.ini file needs to be edited to accommodate files [which in retrospect, seems more likely in this case].
    What php.ini setting are you talking about?

    Take a look at the error he posted in the first post and I reposted in my last post. I don't think he would be getting this error, if the file he wants to copy 1) exists, and 2) he has the path right.

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
  •