SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Who turned the lights out !! Mandes's Avatar
    Join Date
    May 2005
    Location
    S.W. France
    Posts
    2,496
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    FTP Transfer ... but not with Curl or FTP lib

    Yep you read that right

    ive got a small (haha) job on for a company where I need to upload files to various remote servers via FTP.

    however the host they are using (Amen in France) seems to have nicely blocked all attempts to get this working.

    They have told me that they disable the PHP FTP library, OK I say, how about cURL, no thats enabled ... however try as I might I cant get any upload to initiate from this hosting account, if I move the script over to my servers it works fine.

    Anyone got any clever ideas ? heres the simple upload script Im using

    PHP Code:
    <?php
     $ch 
    curl_init();
     
    $localfile "picture.jpg";
     
    $fp fopen($localfile'r');
     
    curl_setopt($chCURLOPT_URL"ftp://user:pass@ftp.domaine.com/public/www/".$localfile);
      
    curl_setopt($chCURLOPT_UPLOAD1);
     
    curl_setopt($chCURLOPT_INFILE$fp);
     
    curl_setopt($chCURLOPT_INFILESIZEfilesize($localfile));
     
    curl_exec ($ch);
     
    $error_no curl_errno($ch);
     
    curl_close ($ch);
     
    if (
    $error_no == 0) {
     
    $message "File uploaded successfully.";
     } else {
     
    $message "File upload error";
     }
     echo 
    $message;
     
    ?>
    I really wanted to keep it all on this server, my fallback plan would be a seperate script on my server that fetches the files then puts them on the remote servers, but thats getting messy.

    TIA
    A Little Knowledge Is A Very Dangerous Thing.......
    That Makes Me A Lethal Weapon !!!!!!!!

    Contract PHP Programming

  2. #2
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Hi, welcome back Mandes!

    There was a discussion last week on streams. There might be something useful in there ...

  3. #3
    Avid Logophile silver trophy
    ParkinT's Avatar
    Join Date
    May 2006
    Location
    Central Florida
    Posts
    2,329
    Mentioned
    191 Post(s)
    Tagged
    4 Thread(s)
    I know your description of the problem included "via FTP". But I wonder if that is an absolute requirement.

    Have you considered SSH or SCP?
    Don't be yourself. Be someone a little nicer. -Mignon McLaughlin, journalist and author (1913-1983)


    Git is for EVERYONE
    Literally, the best app for readers.
    Make Your P@ssw0rd Secure
    Leveraging SubDomains


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
  •