本文整理汇总了PHP中Ftp::forge方法的典型用法代码示例。如果您正苦于以下问题:PHP Ftp::forge方法的具体用法?PHP Ftp::forge怎么用?PHP Ftp::forge使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ftp
的用法示例。
在下文中一共展示了Ftp::forge方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: action_ajax_test_ftp
public function action_ajax_test_ftp()
{
// is ajax
if (!\Input::is_ajax()) {
\Response::redirect(\Uri::create('admin'));
}
// check permission
if (\Model_AccountLevelPermission::checkAdminPermission('config_global', 'config_global') == false) {
\Session::set_flash('form_status', array('form_status' => 'error', 'form_status_message' => \Lang::get('admin_permission_denied', array('page' => \Uri::string()))));
return null;
}
if (\Input::method() == 'POST') {
// get post value and test connection
$config['hostname'] = trim(\Input::post('hostname'));
$config['username'] = trim(\Input::post('username'));
$config['password'] = trim(\Input::post('password'));
$config['port'] = (int) trim(\Input::post('port'));
$config['passive'] = trim(\Input::post('passive')) == 'true' ? true : false;
$config['ssl_mode'] = false;
$config['debug'] = false;
$basepath = trim(\Input::post('basepath'));
// connect to ftp
$ftp = \Ftp::forge($config);
$ftp->connect();
$ftp->change_dir($basepath);
$files = $ftp->list_files();
$ftp->close();
$output = array();
if ($files !== false) {
$output['form_status'] = 'success';
$output['form_status_message'] = \Lang::get('config_ftp_connected_check_basepath_from_dir_structure_below');
natsort($files);
$output['list_files'] = '<ul>';
foreach ($files as $file) {
$output['list_files'] .= '<li>' . $file . '</li>';
}
$output['list_files'] .= '</ul>';
} else {
// got false from list_files means cannot connect
$output['form_status'] = 'error';
$output['form_status_message'] = \Lang::get('config_ftp_could_not_connect_to_server');
}
// clear no use variables
unset($basepath, $config, $file, $files, $ftp);
// send out json values
$response = new \Response();
$response->set_header('Content-Type', 'application/json');
$response->body(json_encode($output));
return $response;
}
}
示例2: with_ftp
/**
* Upload files with Ftp
*
* @param string|array The name of the config group to use, or a configuration array.
* @param bool Automatically connect to this server.
*/
public static function with_ftp($config = 'default', $connect = true)
{
static::$with_ftp = \Ftp::forge($config, $connect);
}
示例3: with_ftp
/**
* Upload files with FTP
*
* @param
* string|array The name of the config group to use, or a configuration array.
* @param
* bool Automatically connect to this server.
*/
public static function with_ftp($config = 'default', $connect = true)
{
if (static::$with_ftp = \Ftp::forge($config, $connect)) {
// if we have an ftp object, activate the move callback
static::$upload->setConfig('moveCallback', '\\Upload\\move_callback');
} else {
// creating the ftp object failed, disable the callback
static::$upload->setConfig('moveCallback', null);
}
}