#1
  1. No Profile Picture
    PHP Geek
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2002
    Posts
    37
    Rep Power
    13

    Problem with FTP Transfer


    I have a script I'm using for my file system which opens a remote file, opens an FTP connection to a server, and uploads the file to the FTP server. This works fine, unless there's a big file. The problem is that with a big file, it takes longer to transfer it. When the transfer passes a certain point(I'm not sure how long it is), it restarts. For example, if it's transferring a 50 MB file to the server, it'll be doing just fine until around 12-13 MB and then I'll refresh the FTP and it'll be at 1 MB, until it does it again. Here's the code:

    PHP Code:
    $fp fopen($url"r");
    if(!
    $fp)
        
    ErrorExit("Could not open file!");

    // ...

    DebugPrint("Now uploading to $path");
    set_time_limit(1800); // 1800s = 30min
    $beforetime getmicrotime();
    DebugPrint("Resource ID of FTP conn is $conn");
    DebugPrint("Resource ID of file itself is $fp");
    $status ftp_fput($conn$path$fpFTP_BINARY);
    $aftertime getmicrotime(); 
    Any ideas?
  2. #2
  3. Always Spell Chek
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2002
    Location
    NJ, USA
    Posts
    338
    Rep Power
    12
    About how much time would say between when you start the download and when it crashes?
    Programming is easy. It's the thinking that's hard.

    Search the forums before you ask your question.
    PHP | MySQL websites. Visit them, read them, cherish them.
    Read the posting rules, before you post.
    See if your question has been answered already.
  4. #3
  5. Wiser? Not exactly.
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    May 2001
    Location
    Bonita Springs, FL
    Posts
    5,905
    Rep Power
    3969

    Try local


    Might try saving the URL to a local tmp file and then use ftp_put to upload that.
  6. #4
  7. No Profile Picture
    PHP Geek
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2002
    Posts
    37
    Rep Power
    13
    Originally posted by maytricks
    About how much time would say between when you start the download and when it crashes?
    Maybe 5-10 minutes, closer to 5.
  8. #5
  9. Always Spell Chek
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2002
    Location
    NJ, USA
    Posts
    338
    Rep Power
    12
    Try using the IP address in the url and see if it happens. I seem to remember reading somewhere that ftp functions have a problem resolving hostnames.
    Programming is easy. It's the thinking that's hard.

    Search the forums before you ask your question.
    PHP | MySQL websites. Visit them, read them, cherish them.
    Read the posting rules, before you post.
    See if your question has been answered already.
  10. #6
  11. No Profile Picture
    PHP Geek
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2002
    Posts
    37
    Rep Power
    13
    The FTP function is using a file pointer, not an actual URL with hostnames. I can't use the IP because the webservers' domains and IPs are the exact same(typing in the IP does not give the same results as typing in the host name).
  12. #7
  13. No Profile Picture
    PHP Geek
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2002
    Posts
    37
    Rep Power
    13
    *bump*

IMN logo majestic logo threadwatch logo seochat tools logo