Results 1 to 8 of 8
  1. #1
    ABW Ambassador
    Join Date
    January 18th, 2005
    Posts
    2,419
    I've got a php file I'm writing to download some datafeeds from another server and the ftp_get fails with an error opening file. I changed the code so that I would open the file myself and use ftp_fget instead and as I suspected, I got a file permission error opening the file.

    I'd appreciate any details you can suggest towards resolving this.

  2. #2
    ABW Veteran Student Heyder's Avatar
    Join Date
    January 18th, 2005
    Posts
    5,482
    Not much experience with this one so bear with me. My point may be null. lol

    Is it possible that the authentication is being done as user apache instead of whatever you need it to be? example: ftp username apache instead of username happypoon

    like I said I don't have much experience with this yet but thought I'd try.

  3. #3
    ABW Ambassador
    Join Date
    January 18th, 2005
    Posts
    2,419
    I ended up making a directory specifically for the downloaded datafeeds and did a chmod on the directory to allow full privledges and then the ftp worked.

    I'd rather not take this approach for obvious reasons, but I did also password protect the directory (so that you'd have to figure out the user id and password before you could do anything in the directory).

    If there are other approaches other than chmod to grant full access I'd still be interested in hearing them.

    Thanks for the stab at it anyway Heyder. Seen any bats lately? LOL

  4. #4
    ABW Ambassador
    Join Date
    January 18th, 2005
    Posts
    4,423
    Are you using a control panel, maybe ensim? I think they cripple the php ftp commands, or at least there are versions that have it crippled, haven't checked the latest.

    Chet

  5. #5
    pph Expert! Gordon's Avatar
    Join Date
    January 18th, 2005
    Location
    Edmonton Canada
    Posts
    5,781
    just a wild stab here happypoon but is it anything to do with the linkshare merchandiser feeds?
    I'm having trouble getting them myself, I can get all my other other feeds downloaded just fine but for some reason the merchandiser feed is giving me problems. I've got them looking into now, if your problem is related I'll post their reply.
    One day parasites and their ilk will be made illegal, I bet a few Lawyers will be pissed off when the day comes.
    Mr. Spitzer is fetching it nearer

    YouTrek

  6. #6
    ABW Ambassador
    Join Date
    January 18th, 2005
    Posts
    2,419
    Yo Gordon,

    The script is brand new and isn't actually downloading any datafeeds yet so no. I was testing my coding (against an ftp area on one of my other sites) when the issue presened itself.

  7. #7
    Full Member
    Join Date
    January 18th, 2005
    Posts
    284
    Did you host install Phpsuexec?

    I had a host, without warning install it so that PHP ran as a CGI module.

    Screwed up all my permissions as PHP no longer ran as Nobody making it impossible to do uploads into a different directory.
    CharPaula
    Staying focused on the bottomline

  8. #8
    Newbie
    Join Date
    January 18th, 2005
    Location
    Mount Pleasant, WI
    Posts
    41
    FTP functions are not installed by default with PHP, so be sure your host included them. I would think you would get an undefined function error if it wasn't though...

    Here's a simple class I wrote that I use successfully for all of my FTP downloads. It takes 5 variables. You should not need to change anything here:

    class ftp_download
    {
    var $host; // ftp.remotesite.com
    var $user; // username
    var $pass; // password
    var $file; // path to remote file
    var $save; // path and filename where you want file saved

    function get_file()
    {
    echo "Connecting to $this->host...<br />";
    $conn = ftp_connect($this->host);
    if (ftp_login($conn, $this->user, $this->pass))
    echo "Logged into $this->host...<br />";
    else {
    echo 'Could not log in';
    exit;
    }
    echo 'Getting file from server... <br />';
    $fp = fopen($this->save, 'w');
    if (!ftp_fget($conn, $fp, $this->file, FTP_ASCII))
    {
    echo 'Error, could not download file';
    fclose($fp);
    ftp_quit($conn);
    exit;
    }
    fclose($fp);
    echo 'File download successful. <br />';
    }
    }

    To use the class, change the appropriate parts here...

    $a = new ftp_download();

    $a->host = 'ftp.remotehost.com';
    $a->user = 'user';
    $a->pass = 'password';
    $a->file = '/datafeed.csv';
    $a->save = '/home/yoursite/public_html/downloads/datafeed.csv';

    $a->get_file();

    Good luck!
    ScottyB

  9. Newsletter Signup

+ Reply to Thread

Similar Threads

  1. Political Issues Forum - permission?
    By tmd5 in forum Midnight Cafe'
    Replies: 22
    Last Post: November 10th, 2004, 10:40 AM
  2. Permission ??
    By walton in forum Midnight Cafe'
    Replies: 2
    Last Post: June 29th, 2004, 08:13 PM

Posting Permissions

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