Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7780851
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T19:02:20+00:00 2026-06-01T19:02:20+00:00

Hey guys I have my script here that is supposed to do some stuff

  • 0

Hey guys I have my script here that is supposed to do some stuff then delete a file, unfortunetly my files never unlink. I”m wondering what the reason for this might be? Permissions was the only thing I could think of, or maybe the output buffer is messing up? I really don’t know, but would appreciate some advice on how to handle it. Issue in question is that last IF() block.

public function remoteFtp() {
    $enabled = Mage::getStoreConfig('cataloginventory/settings/use_ftp');
    $remove = Mage::getStoreConfig('cataloginventory/settings/ftp_remove_file');
    if ($enabled == 0) {
        return true;
    }

    $base_path = Mage::getBaseDir('base');


    $ftp_url = Mage::getStoreConfig('cataloginventory/settings/ftp_url');
    $ftp_user = Mage::getStoreConfig('cataloginventory/settings/ftp_user');
    $ftp_pass = Mage::getStoreConfig('cataloginventory/settings/ftp_password');
    $ftp_remote_dir = Mage::getStoreConfig('cataloginventory/settings/ftp_remote_dir');
    $ftp_filename_filter = Mage::getStoreConfig('cataloginventory/settings/ftp_remote_filename');

    $ftp_file = $base_path . '/edi/working/working.edi';

    $handle = fopen($ftp_file, 'w');
    $conn_id = ftp_connect($ftp_url);

    ftp_login($conn_id, $ftp_user, $ftp_pass) or die("unable to login");

    if ($ftp_remote_dir) {
        ftp_chdir($conn_id, $ftp_remote_dir);
    }

    //is there a file
    $remote_list = ftp_nlist($conn_id, ".");

    $exists = count($remote_list);

    if ($exists > 0) {
        $len = strlen($ftp_filename_filter) - 1;


        foreach ($remote_list as $name) {
            if (substr($ftp_filename_filter, 0, 1) == "*") {

                if (substr($name, '-' . $len) == substr($ftp_filename_filter, '-' . $len)) {
                    $ftp_remote_name = $name;
                }
            }
            if (substr($ftp_filename_filter, strlen($name) - 1) == "*") {
                if (substr($ftp_filename_filter, 0, $len) == substr($name, 0, $len)) {
                    $ftp_remote_name = $name;
                }
            }
            if ($ftp_filename_filter == $name) {
                $ftp_remote_name = $name;
            }
        }
    }


    if (ftp_fget($conn_id, $handle, $ftp_remote_name, FTP_ASCII, 0)) {
        echo "successfully written to $ftp_file <br />";
        if ($remove == 1) {
            ftp_delete($conn_id, $ftp_remote_name);
        }
    } else {
        echo "There was a problem while downloading $ftp_remote_name to $ftp_file <br />";
    }

    ftp_close($conn_id);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T19:02:21+00:00Added an answer on June 1, 2026 at 7:02 pm

    The answer was that the system variable $remove = Mage::getStoreConfig('cataloginventory/settings/ftp_remove_file'); was set to BOOL(false)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey guys I have one more question lol. I am using a script that
Hey guys quick question, I have an add remove script that will add a
Hey guys I've got a text file that a script creates (specifically dmidecode >
Hey guys I have an admin page that checks if you are admin before
Hey guys I have a little issue here. I have a panel where I
Hey guys I have a query that currently finds the latest comment for each
Hey guys, I have developed a small site that i would like to embed
Hey guys, I have a program that uses ajax to send a post to
Hey guys, I have a bit of a problem that I can't solve. I'm
Hey Guys, i have a big problem with my jQuery Datepicker Script. I use

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.