CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    Jul 1999
    Location
    Poland
    Posts
    278

    ftp_put(), problem with relative path

    Hello

    I would like to upload a file:
    script php with ftp_put() is on the: /public_html/mleko/ftp.php
    source file is on the /public_html/mleko/temp.txt
    remote file should be uploaded to /public_ftp/mleko/uploadedfile.txt

    could you please tell me what is wrong with code as below:
    PHP Code:
    $result ftp_put'/public_ftp/mleko/uploadedfile.txt''temp.txt'FTP_ASCII ); 
    I receive an error:
    "... no such file or directory ... "

    thanks in advance
    andrzej

  2. #2
    Join Date
    Oct 2006
    Location
    Sweden
    Posts
    3,654

    Re: ftp_put(), problem with relative path

    Have no experience in this field but my guess is that the default directory is not where temp.txt is located. Are you calling/running ftp.php from another dir?
    Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible, you are, by
    definition, not smart enough to debug it.
    - Brian W. Kernighan

    To enhance your chance's of getting an answer be sure to read
    http://www.codeguru.com/forum/announ...nouncementid=6
    and http://www.codeguru.com/forum/showthread.php?t=366302 before posting

    Refresh your memory on formatting tags here
    http://www.codeguru.com/forum/misc.php?do=bbcode

    Get your free MS compiler here
    https://visualstudio.microsoft.com/vs

  3. #3
    Join Date
    May 2002
    Posts
    10,943

    Re: ftp_put(), problem with relative path

    Very simple, you're accessing a directory that isn't there...exactly what the message says. Make sure the path you're writing to already exists and the root directory you're starting from is correct.
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  4. #4
    Join Date
    Apr 2009
    Posts
    598

    Re: ftp_put(), problem with relative path

    The root directory is the one defined in a configuration file of Apache (if that's your server), and it is likely it is different from the root directory of the hard drive.
    Personnally, I avoid troubles by using relative paths (a relative path is a path that does not start with "/").

  5. #5
    Join Date
    Jul 1999
    Location
    Poland
    Posts
    278

    Re: ftp_put(), problem with relative path

    thanks for the reply,

    could you please give me the example, what my ftp_put() function parameter should be

    to clarify:

    • my ftp.php script ( which includes ftp_put() ) is located on the:
      /public_html/mleko/ftp.php


    • my file which need to be uploaded is located on the:
      /public_html/mleko/tmp.txt


    • I need to upload the tmp.file to:
      /public_ftp/data/ftp.php

    I did it as follows ( but the error '..no such file or directory ..' is generated
    PHP Code:
    $remote_path='/public_ftp/data/mleko/';
    //$remote_path='../../public_ftp/data/mleko/'; // also doesn't work
    $local_file_name='tmp.txt';
    $new_file_name='uploaded.txt';
    $result ftp_put($remote_path $new_file_name,  $local_file_name,  FTP_ASCII ); 
    thank you in advance
    Andrzej
    Last edited by Andrzej; March 15th, 2011 at 11:16 AM.

  6. #6
    Join Date
    Jul 1999
    Location
    Poland
    Posts
    278

    Re: ftp_put(), problem with relative path (solved)

    I solved ...

    $remote_path must be RELAVIVE PATH TO YOUR LOGIN DIRECTORY
    I have change my login directory and now it works OK !

    this is OK
    $remote_path='../../public_ftp/data/mleko/';
    but the ftp login directory must be to the 'root' ( / )

  7. #7
    Join Date
    May 2002
    Posts
    10,943

    Re: ftp_put(), problem with relative path

    Quote Originally Posted by PeejAvery View Post
    ... and the root directory you're starting from is correct.
    That's what this meant.
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  8. #8
    Join Date
    Jul 1999
    Location
    Poland
    Posts
    278

    Re: ftp_put(), problem with relative path

    Quote Originally Posted by PeejAvery View Post
    That's what this meant.
    thanks PeejAvery, know I've understood your unswer.

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

Featured