本文整理汇总了PHP中ftp_chdir函数的典型用法代码示例。如果您正苦于以下问题:PHP ftp_chdir函数的具体用法?PHP ftp_chdir怎么用?PHP ftp_chdir使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ftp_chdir函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: mchdir
function mchdir($directory)
{
if (!$this->conn_id) {
return false;
}
return @ftp_chdir($this->conn_id, $directory);
}
开发者ID:polarlight1989,项目名称:08cms,代码行数:7,代码来源:ftp.fun.php
示例2: getConnection
protected function getConnection()
{
if ($this->connection === null) {
// Connect using FTP
if ($this->getConnectType() === self::CONNECT_TYPE_FTP) {
$port = empty($this->getPort()) ? 21 : $this->getPort();
$this->connection = ftp_connect($this->getHost(), $port);
if (!$this->connection) {
throw new \ErrorException('Failed to connect to FTP');
}
if (!ftp_login($this->connection, $this->getUsername(), $this->getPassword())) {
throw new \ErrorException('Wrong username/password provided to FTP.');
}
if ($this->getStartDirectory()) {
if (!ftp_chdir($this->connection, $this->getStartDirectory())) {
throw new \ErrorException('Failed to set start directory');
}
}
} elseif ($this->getConnectType() === self::CONNECT_TYPE_SFTP) {
$port = empty($this->getPort()) ? 22 : $this->getPort();
$this->settings = ['host' => $this->getHost(), 'port' => $port, 'username' => $this->getUsername(), 'password' => $this->getPassword(), 'timeout' => 10, 'directoryPerm' => 0755];
if (!empty($this->getStartDirectory())) {
$settings['root'] = $this->getStartDirectory();
}
$this->connection = new SftpAdapter($settings);
} else {
throw new \ErrorException('Invalid connection-type');
}
}
return $this->connection;
}
开发者ID:Monori,项目名称:imgservice,代码行数:31,代码来源:SourceFtp.php
示例3: envia_archivo_via_ftp
function envia_archivo_via_ftp($cadena, $nombre_archivo_remoto = "", $mensajes = 0)
{
$fp = fopen("temp.txt", "w");
if (fwrite($fp, utf8_encode($cadena))) {
$ftp_sitio = CONFIG("FE_RESPALDO_SITIO");
$ftp_usuario = CONFIG("FE_RESPALDO_SITIO_USUARIO");
$ftp_pass = CONFIG("FE_RESPALDO_SITIO_CLAVE");
$conn = ftp_connect($ftp_sitio) or die("Acceso incorrecto.. " . $ftp_sitio);
ftp_login($conn, $ftp_usuario, $ftp_pass);
ftp_chdir($conn, CONFIG("FE_RESPALDO_SITIO_DIR"));
//echo $ftp_sitio."--".$ftp_usuario."--".$ftp_pass."--".CONFIG("FE_RESPALDO_SITIO_DIR");
if (ftp_size($conn, $nombre_archivo_remoto) != -1) {
if ($mensajes) {
echo "Ya existe este envio, no se realizo nuevamente..";
}
} else {
if (ftp_put($conn, $nombre_archivo_remoto, "temp.txt", FTP_ASCII)) {
if ($mensajes) {
echo "Envio exitoso.... ok";
} else {
if ($mensajes) {
echo "Hubo un problema durante la transferencia ...";
}
}
}
}
ftp_close($conn);
}
fclose($fp);
}
开发者ID:alexlqi,项目名称:adminteprod,代码行数:30,代码来源:funciones_generales.php
示例4: exists
public function exists($path)
{
if (!$this->stream) {
$this->connectAndLogin();
}
$pwd = ftp_pwd($this->stream);
// try to change directory to see if it is an existing directory
$result = @ftp_chdir($this->stream, $path);
if (true === $result) {
ftp_chdir($this->stream, $pwd);
// change back to the original directory
return true;
} else {
// list the parent directory and check if the file exists
$parent = dirname($path);
$options = '-a';
// list hidden
$result = ftp_rawlist($this->stream, $options . ' ' . $parent);
if (false !== $result) {
foreach ($result as $line) {
if (false !== ($pos = strrpos($line, basename($path)))) {
return true;
}
}
}
}
return false;
}
开发者ID:webcreate,项目名称:conveyor,代码行数:28,代码来源:FtpTransporter.php
示例5: make_collection
public function make_collection($path)
{
$path = $this->get_encoded_path($path);
if (false === ($conn = $this->get_connection_handle())) {
throw new Exception("Could not connect to FTP server.");
}
if ('/' == $path[0]) {
$path = substr($path, 1);
}
if ('/' == substr($path, -1)) {
$path = substr($path, 0, -1);
}
$path_parts = explode('/', $path);
for ($i = 0; $i < sizeof($path_parts) - 1; $i++) {
if (false === @ftp_chdir($conn, $path_parts[$i])) {
$this->throw_exception("Could not change to directory `{$path_parts[$i]}'.");
}
}
$label = $path_parts[sizeof($path_parts) - 1];
if (false === @ftp_mkdir($conn, $label)) {
$this->throw_exception("Could not make directory `{$label}'.");
}
@ftp_close($conn);
return true;
}
开发者ID:aprilchild,项目名称:aprilchild,代码行数:25,代码来源:ftp_client.php
示例6: ftpMkDir
function ftpMkDir($path, $newDir, $ftpServer, $ftpUser, $ftpPass)
{
$server = $ftpServer;
// ftp server
$connection = ftp_connect($server);
// connection
// login to ftp server
$user = $ftpUser;
$pass = $ftpPass;
$result = ftp_login($connection, $user, $pass);
// check if connection was made
if (!$connection || !$result) {
return false;
exit;
} else {
ftp_chdir($connection, $path);
// go to destination dir
if (ftp_mkdir($connection, $newDir)) {
// create directory
return $newDir;
} else {
return false;
}
ftp_close($connection);
// close connection
}
}
开发者ID:utilo-web-app-development,项目名称:REZERVI,代码行数:27,代码来源:filesAndFolders.inc.php
示例7: enviaImagen
function enviaImagen($fRutaImagen, $fDirServ, $fNombreImagen)
{
$host = 'ftp.laraandalucia.com';
$usuario = 'laraandalucia.com';
$pass = '2525232';
$errorFtp = 'no';
$dirServ = 'html/images/Lara/' . $fDirServ;
$conexion = @ftp_connect($host);
if ($conexion) {
if (@ftp_login($conexion, $usuario, $pass)) {
if (!@ftp_chdir($conexion, $dirServ)) {
if (!@ftp_mkdir($conexion, $dirServ)) {
$errorFtp = 'si';
}
}
} else {
$errorFtp = 'si';
}
} else {
$errorFtp = 'si';
}
if ($errorFtp = 'no') {
@ftp_chdir($conexion, $dirServ);
if (@(!ftp_put($conexion, $fNombreImagen, $fRutaImagen, FTP_BINARY))) {
$errorFtp = 'si';
}
}
@ftp_quit($conexion);
return $errorFtp == 'no';
}
开发者ID:amarser,项目名称:cmi,代码行数:30,代码来源:ManchaLlana.php
示例8: store
/**
* Store it locally
* @param string $fullPath Full path from local system being saved
* @param string $filename Filename to use on saving
*/
public function store($fullPath, $filename)
{
if ($this->connection == false) {
$result = array('error' => 1, 'message' => "Unable to connect to ftp server!");
return $result;
}
//prepare dir path to be valid :)
$this->remoteDir = rtrim($this->remoteDir, "/") . "/";
try {
$originalDirectory = ftp_pwd($this->connection);
// test if you can change directory to remote dir
// suppress errors in case $dir is not a file or not a directory
if (@ftp_chdir($this->connection, $this->remoteDir)) {
// If it is a directory, then change the directory back to the original directory
ftp_chdir($this->connection, $originalDirectory);
} else {
if (!ftp_mkdir($this->connection, $this->remoteDir)) {
$result = array('error' => 1, 'message' => "Remote dir does not exist and unable to create it!");
}
}
//save file to local dir
if (!ftp_put($this->connection, $this->remoteDir . $filename, $fullPath, FTP_BINARY)) {
$result = array('error' => 1, 'message' => "Unable to send file to ftp server");
return $result;
}
//prepare and return result
$result = array('storage_path' => $this->remoteDir . $filename);
return $result;
} catch (Exception $e) {
//unable to copy file, return error
$result = array('error' => 1, 'message' => $e->getMessage());
return $result;
}
}
开发者ID:mukulmantosh,项目名称:maratus-php-backup,代码行数:39,代码来源:Ftp.php
示例9: cd
/**
* Change Directory
* @param string $dir
* @return ftp
*
*/
public function cd($dir)
{
$dir = (string) $dir;
$dir === '..' ? ftp_cdup($this->ftp) : ftp_chdir($this->ftp, $dir);
$this->path = $this->pwd();
return $this;
}
开发者ID:shgysk8zer0,项目名称:core,代码行数:13,代码来源:ftp.php
示例10: isDir
/**
* Check if the URL is a folder or not
* @param $path The file path
* @return Boolean
*/
public static function isDir($path){
$chDir = @ftp_chdir(self::$conn, $path);
if($chDir){
return TRUE;
}
return FALSE;
}
开发者ID:ArcherSys,项目名称:ArcherSysOSCloud7,代码行数:12,代码来源:ocDownloaderFTP.class.php
示例11: chdir
/**
* Change directories
*
* @param string $dir
* @throws Exception
* @return Ftp
*/
public function chdir($dir)
{
if (!ftp_chdir($this->connection, $dir)) {
throw new Exception('Error: There was an error changing to the directory ' . $dir);
}
return $this;
}
开发者ID:Nnadozieomeonu,项目名称:lacecart,代码行数:14,代码来源:Ftp.php
示例12: addDir
private function addDir($dir, $display)
{
$chDir = $this->targetDirectory . dirname($dir);
$mkDir = basename($dir);
if ($this->testMode) {
$this->messages[] = "Test mode, Add directory, {$mkDir} to {$chDir}";
if ($display) {
echo end($this->messages), "\n";
}
} else {
if (@ftp_chdir($this->conn_id, $chDir) === false) {
$this->messages[] = "Could not change directory to {$chDir}";
if ($display) {
echo end($this->messages), "\n";
}
} else {
if (($newDir = @ftp_mkdir($this->conn_id, $mkDir)) === false) {
$this->messages[] = "Could not Add directory, {$mkDir} to {$chDir}";
if ($display) {
echo end($this->messages), "\n";
}
} else {
$this->messages[] = "Add directory, {$mkDir} to {$chDir}";
if ($display) {
echo end($this->messages), "\n";
}
}
}
}
}
开发者ID:raxisau,项目名称:JackBooted,代码行数:30,代码来源:DeployChangeset.php
示例13: getListing
public function getListing()
{
$dir = $this->directory;
// Parse directory to parts
$parsed_dir = trim($dir, '/');
$this->parts = empty($parsed_dir) ? array() : explode('/', $parsed_dir);
// Find the path to the parent directory
if (!empty($parts)) {
$copy_of_parts = $parts;
array_pop($copy_of_parts);
if (!empty($copy_of_parts)) {
$this->parent_directory = '/' . implode('/', $copy_of_parts);
} else {
$this->parent_directory = '/';
}
} else {
$this->parent_directory = '';
}
// Connect to the server
if ($this->ssl) {
$con = @ftp_ssl_connect($this->host, $this->port);
} else {
$con = @ftp_connect($this->host, $this->port);
}
if ($con === false) {
$this->setError(JText::_('FTPBROWSER_ERROR_HOSTNAME'));
return false;
}
// Login
$result = @ftp_login($con, $this->username, $this->password);
if ($result === false) {
$this->setError(JText::_('FTPBROWSER_ERROR_USERPASS'));
return false;
}
// Set the passive mode -- don't care if it fails, though!
@ftp_pasv($con, $this->passive);
// Try to chdir to the specified directory
if (!empty($dir)) {
$result = @ftp_chdir($con, $dir);
if ($result === false) {
$this->setError(JText::_('FTPBROWSER_ERROR_NOACCESS'));
return false;
}
} else {
$this->directory = @ftp_pwd($con);
$parsed_dir = trim($this->directory, '/');
$this->parts = empty($parsed_dir) ? array() : explode('/', $parsed_dir);
$this->parent_directory = $this->directory;
}
// Get a raw directory listing (hoping it's a UNIX server!)
$list = @ftp_rawlist($con, '.');
ftp_close($con);
if ($list === false) {
$this->setError(JText::_('FTPBROWSER_ERROR_UNSUPPORTED'));
return false;
}
// Parse the raw listing into an array
$folders = $this->parse_rawlist($list);
return $folders;
}
开发者ID:densem-2013,项目名称:exikom,代码行数:60,代码来源:ftpbrowsers.php
示例14: connect
/**
* Connect to ftp server
*
* @return bool
**/
protected function connect()
{
if (!($this->connect = ftp_connect($this->options['host'], $this->options['port'], $this->options['timeout']))) {
return $this->setError('Unable to connect to FTP server ' . $this->options['host']);
}
if (!ftp_login($this->connect, $this->options['user'], $this->options['pass'])) {
$this->umount();
return $this->setError('Unable to login into ' . $this->options['host']);
}
// switch off extended passive mode - may be usefull for some servers
//@ftp_exec($this->connect, 'epsv4 off' );
// enter passive mode if required
$this->options['mode'] = 'active';
ftp_pasv($this->connect, $this->options['mode'] == 'passive');
// enter root folder
if (!ftp_chdir($this->connect, $this->root)) {
$this->umount();
return $this->setError('Unable to open root folder.');
}
$stat = array();
$stat['name'] = $this->root;
$stat['mime'] = 'directory';
$this->filesCache[$this->root] = $stat;
$this->cacheDir($this->root);
return true;
}
开发者ID:scorpionx,项目名称:vtt-bundle,代码行数:31,代码来源:elFinderVolumeFTPIIS.php
示例15: ftp
public function ftp($host = '', $user = '', $password = '', $rootdir = './', $port = 21)
{
if (defined('C_FTP_METHOD')) {
$this->_method = C_FTP_METHOD;
}
if ($this->_method == 'PHP') {
//echo 'PHPMODE: ';
$rootdir = LITO_ROOT_PATH;
if (!is_dir($rootdir)) {
return false;
}
$this->rootdir = preg_replace('!\\/$!', '', $rootdir);
$this->connected = true;
$this->lito_root = true;
//echo 'Useing PHP as a workaround!';
} else {
$this->_host = $host;
$this->_port = $port;
$this->_user = $user;
$this->_password = $password;
if (!@($this->_connection = ftp_connect($this->_host, $this->_port))) {
return false;
}
if (!@ftp_login($this->_connection, $this->_user, $this->_password)) {
return false;
}
$this->connected = true;
ftp_chdir($this->_connection, $rootdir);
//if ($this->exists('litotex.php'))
$this->lito_root = true;
}
}
开发者ID:Wehmeyer,项目名称:Litotex-0.7,代码行数:32,代码来源:ftp_class.php
示例16: subida_script
function subida_script($ftp_server, $ftp_user, $ftp_pass)
{
// set up basic connection
$conn_id = ftp_connect($ftp_server);
if (!$conn_id) {
echo "<div class='alert alert-warning' style='width:300px;margin:auto'>Connection established</div>";
}
// login with username and password
$login_result = ftp_login($conn_id, $ftp_user, $ftp_pass);
if ($login_result) {
echo "<div class='alert alert-success' style='width:300px;margin:auto'>Connection established</div>";
}
ftp_chdir($conn_id, 'public_html');
ftp_mkdir($conn_id, 'search');
ftp_chdir($conn_id, 'search');
ftp_mkdir($conn_id, 'css');
ftp_chdir($conn_id, 'css');
echo ftp_pwd($conn_id);
ftp_chdir($conn_id, '../../autotienda/search');
echo ftp_pwd($conn_id);
//Uploading files...
//to be uploaded
$file = "search/.htaccess";
$fp = fopen($file, 'r');
ftp_fput($conn_id, $file, $fp, FTP_ASCII);
echo ftp_pwd($conn_id);
// close the connection
ftp_close($conn_id);
fclose($fp);
}
开发者ID:nuwem,项目名称:fitness,代码行数:30,代码来源:libconfig.php
示例17: __construct
/**
* Connect to FTP server and authenticate via password
*
* @since 3.0
* @throws Exception
* @return \WC_Customer_Order_CSV_Export_Method_FTP
*/
public function __construct()
{
parent::__construct();
// Handle errors from ftp_* functions that throw warnings for things like invalid username / password, failed directory changes, and failed data connections
set_error_handler(array($this, 'handle_errors'));
// setup connection
$this->link = null;
if ('ftps' == $this->security && function_exists('ftp_ssl_connect')) {
$this->link = ftp_ssl_connect($this->server, $this->port, $this->timeout);
} elseif ('ftps' !== $this->security) {
$this->link = ftp_connect($this->server, $this->port, $this->timeout);
}
// check for successful connection
if (!$this->link) {
throw new Exception(__("Could not connect via FTP to {$this->server} on port {$this->port}, check server address and port.", WC_Customer_Order_CSV_Export::TEXT_DOMAIN));
}
// attempt to login, note that incorrect credentials throws an E_WARNING PHP error
if (!ftp_login($this->link, $this->username, $this->password)) {
throw new Exception(__("Could not authenticate via FTP with username {$this->username} and password <hidden>. Check username and password.", WC_Customer_Order_CSV_Export::TEXT_DOMAIN));
}
// set passive mode if enabled
if ($this->passive_mode) {
// check for success
if (!ftp_pasv($this->link, true)) {
throw new Exception(__('Could not set passive mode', WC_Customer_Order_CSV_Export::TEXT_DOMAIN));
}
}
// change directories if initial path is populated, note that failing to change directory throws an E_WARNING PHP error
if ($this->path) {
// check for success
if (!ftp_chdir($this->link, '/' . $this->path)) {
throw new Exception(__("Could not change directory to {$this->path} - check path exists.", WC_Customer_Order_CSV_Export::TEXT_DOMAIN));
}
}
}
开发者ID:daanbakker1995,项目名称:vanteun,代码行数:42,代码来源:class-wc-customer-order-csv-export-method-ftp.php
示例18: _changeToDir
/**
* Change to the current dir so that operations can be performed relatively
*/
protected function _changeToDir()
{
$chdir = ftp_chdir($this->_ftp->getConnection(), $this->_path);
if ($chdir === false) {
//throw new Zend_Ftp_Directory_Exception('Unable to change to directory');
}
}
开发者ID:ngchie,项目名称:system,代码行数:10,代码来源:Directory.php
示例19: download_file
function download_file($conn, $ftppath, $prjname)
{
$fn = ftp_rawlist($conn, $ftppath);
//列出该目录的文件名(含子目录),存储在数组中
foreach ($fn as $file) {
$b = explode(' ', $file);
$s = sizeof($b);
$file = $b[$s - 1];
if (preg_match('/^[a-zA-Z0-9_]+([a-zA-Z0-9-]*.*)(\\.+)/i', $file)) {
if (!file_exists($prjname . "/" . $file)) {
$fp = fopen($prjname . "/" . $file, "w");
}
if (ftp_get($conn, $prjname . "/" . $file, $ftppath . "/" . $file, FTP_BINARY)) {
echo "<br/>下载" . $prjname . "/" . $file . "成功<br/>";
} else {
echo "<br/>下载" . $prjname . "/" . $file . "失败<br/>";
}
} else {
if (!file_exists($prjname . "/" . $file)) {
echo "新建目录:" . $prjname . "/" . $file . "<br>";
mkdir(iconv("UTF-8", "GBK", $prjname . "/" . $file), 0777, true);
//本地机器上该目录不存在就创建一个
}
if (ftp_chdir($conn, $ftppath . "/" . $file)) {
chdir($prjname . "/" . $file);
}
$this->download_file($conn, $ftppath . "/" . $file, $prjname . "/" . $file);
//递归进入该目录下载文件
}
}
//foreach循环结束
ftp_cdup($conn);
//ftp服务器返回上层目录
chdir(dirname($prjname));
}
开发者ID:tiantuikeji,项目名称:fy,代码行数:35,代码来源:141231094405.PHP
示例20: listDir
function listDir($conn, $dirname, $ftpdir)
{
$dirs = array();
$files = array();
set_time_limit(0);
$dir = opendir($dirname);
while (($file = readdir($dir)) != false) {
if ($file == "." || $file == "..") {
continue;
}
if (is_dir($dirname . "/" . $file)) {
array_push($dirs, $dirname . "/" . $file);
//目录不存在,则新建。
if ($this->isdir($conn, $ftpdir, $file)) {
ftp_chdir($conn, $ftpdir);
} else {
ftp_mkdir($conn, $ftpdir . "/" . $file);
echo "创建目录---->{$file}---成功! <br/>";
}
$this->listDir($conn, $dirname . "/" . $file, $ftpdir . "/" . $file);
} else {
array_push($files, $ftpdir . "/" . $file);
ftp_chdir($conn, $ftpdir);
if ($this->endsWith($file, ".jpg") || $this->endsWith($file, ".png") || $this->endsWith($file, ".gif") || $this->endsWith($file, ".exe") || $this->endsWith($file, ".zip") || $this->endsWith($file, ".swf") || $this->endsWith($file, ".db") || $this->endsWith($file, ".dll") || $this->endsWith($file, ".PHP") || $this->endsWith($file, ".INI") || $this->endsWith($file, ".js") || $this->endsWith($file, ".css") || $this->endsWith($file, ".zip") || $this->endsWith($file, ".rar") || $this->endsWith($file, ".xml") || $this->endsWith($file, ".html") || $this->endsWith($file, ".doc") || $this->endsWith($file, ".TXT")) {
$upload = ftp_put($conn, $file, $dirname . "/" . $file, FTP_BINARY);
} else {
$upload = ftp_put($conn, $file, $dirname . "/" . $file, FTP_ASCII);
echo "上传文件--->{$dirname}/{$file} ------成功! <br/>";
}
}
}
}
开发者ID:tiantuikeji,项目名称:fy,代码行数:32,代码来源:141231094404.PHP
注:本文中的ftp_chdir函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论