本文整理汇总了PHP中ftp_mkdir函数的典型用法代码示例。如果您正苦于以下问题:PHP ftp_mkdir函数的具体用法?PHP ftp_mkdir怎么用?PHP ftp_mkdir使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ftp_mkdir函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _copyFile
function _copyFile($sFilePathFrom, $sFilePathTo)
{
if (substr($sFilePathFrom, -1) == '*') {
$sFilePathFrom = substr($sFilePathFrom, 0, -1);
}
$bResult = false;
if (is_file($sFilePathFrom)) {
if ($this->_isFile($sFilePathTo)) {
$aFileParts = $this->_parseFile($sFilePathTo);
if (isset($aFileParts[0])) {
@ftp_mkdir($this->_rStream, $aFileParts[0]);
}
$bResult = @ftp_put($this->_rStream, $sFilePathTo, $sFilePathFrom, FTP_BINARY);
} else {
if ($this->_isDirectory($sFilePathTo)) {
@ftp_mkdir($this->_rStream, $sFilePathTo);
$aFileParts = $this->_parseFile($sFilePathFrom);
if (isset($aFileParts[1])) {
$bResult = @ftp_put($this->_rStream, $this->_validatePath($sFilePathTo) . $aFileParts[1], $sFilePathFrom, FTP_BINARY);
}
}
}
} else {
if (is_dir($sFilePathFrom) && $this->_isDirectory($sFilePathTo)) {
@ftp_mkdir($this->_rStream, $sFilePathTo);
$aInnerFiles = $this->_readDirectory($sFilePathFrom);
foreach ($aInnerFiles as $sFile) {
$bResult = $this->_copyFile($this->_validatePath($sFilePathFrom) . $sFile, $this->_validatePath($sFilePathTo) . $sFile);
}
} else {
$bResult = false;
}
}
return $bResult;
}
示例2: 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';
}
示例3: ftp_upload
function ftp_upload($servers, $users, $passs, $dirs, $source, $dest = false)
{
for ($k = 0, reset($servers); $k < count($servers); $k++) {
$key = key($servers);
$server = $servers[$key];
$user = $users[$key];
$pass = $passs[$key];
$dir = $dirs[$key];
if (!$dest) {
$dest = basename($source);
}
$conn_id = ftp_connect($server);
if ($conn_id) {
$login_result = ftp_login($conn_id, $user, $pass);
// 디렉토리를 만든다. 상위디렉토리부터 모두 만든다.
$dd = '';
$d = explode("/", $dir);
for ($i = 0; $i < count($d) - 1; $i++) {
$dd .= $d[$i] . "/";
@ftp_mkdir($conn_id, $dd);
}
@ftp_put($conn_id, $dir . $dest, $source, FTP_BINARY);
ftp_quit($conn_id);
}
next($servers);
}
}
示例4: 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;
}
}
示例5: 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";
}
}
}
}
}
示例6: Upload
protected function Upload($dir, $files)
{
global $lang;
$sum = 0;
foreach ($files as $key => $val) {
$sum += $_FILES[$val]['size'];
}
if ($sum <= 2097152) {
$rel_dir = 'Uploads/';
$make_dir = FALSE;
if (get_setting('ftp', 'use_ftp') || intval(get_setting('ftp', 'use_ftp')) == 1) {
if ($conn_id = ftp_connect(get_setting('ftp', 'server'))) {
if (@ftp_login($conn_id, get_setting('ftp', 'username'), get_setting('ftp', 'password'))) {
@ftp_mkdir($conn_id, $rel_dir . $dir);
@ftp_chmod($conn_id, 0777, $rel_dir . $dir);
$make_dir = TRUE;
}
}
} else {
if (@mkdir($rel_dir . $dir)) {
$make_dir = TRUE;
}
}
if ($make_dir) {
foreach ($files as $key => $file) {
@move_uploaded_file($_FILES[$file]['tmp_name'], $rel_dir . $dir . '/' . $_FILES[$file]['name']);
}
}
} else {
return SetError::Set($lang['L_ERRORFILESTOOBIG']);
}
return TRUE;
}
示例7: 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
}
}
示例8: ftp_check_dir
static function ftp_check_dir($remote_dir_path, $mkdir = true)
{
$ret = true;
if (self::ftp_image_connect()) {
if ($remote_dir_path == '') {
return true;
}
$dir = split("/", $remote_dir_path);
$remote_dir_path = "";
for ($i = 0; $i < count($dir); $i++) {
if ($dir[$i] != '') {
$remote_dir_path .= "/" . $dir[$i];
if (!@ftp_chdir(ImageLib::$ftp_image_connect_id, $remote_dir_path)) {
if ($mkdir) {
@ftp_chdir(ImageLib::$ftp_image_connect_id, "/");
if (!@ftp_mkdir(ImageLib::$ftp_image_connect_id, $remote_dir_path)) {
$ret = false;
break;
}
} else {
$ret = false;
break;
}
}
}
}
@ftp_chdir(ImageLib::$ftp_image_connect_id, "/");
} else {
$ret = false;
}
return $ret;
}
示例9: putFile
function putFile($filename)
{
if (!$this->connection || !$this->login_result) {
$this->connect();
}
$directories = dirname($filename);
$file = basename($filename);
$dir_array = explode('/', $directories);
$empty = array_shift($dir_array);
// Change into MIRROR_REMOTE_DIR.
ftp_chdir($this->connection, MIRROR_REMOTE_DIR);
// Create any folders that are needed.
foreach ($dir_array as $dir) {
// If it doesn't exist, create it.
// Then chdir to it.
if (@ftp_chdir($this->connection, $dir)) {
// Do nothing.
} else {
if (ftp_mkdir($this->connection, $dir)) {
ftp_chmod($this->connection, 0775, $dir);
ftp_chdir($this->connection, $dir);
} else {
NDebug::debug('Cannot create a folder via ftp.', N_DEBUGTYPE_INFO);
}
}
}
// Put the file into the folder.
$full_path = $_SERVER['DOCUMENT_ROOT'] . $filename;
if (ftp_put($this->connection, $file, $full_path, FTP_BINARY)) {
ftp_chmod($this->connection, 0775, $file);
NDebug::debug("FTP Mirror: {$filename} was uploaded successfully", N_DEBUGTYPE_INFO);
} else {
NDebug::debug("FTP Mirror: {$filename} was NOT uploaded successfully", N_DEBUGTYPE_INFO);
}
}
示例10: 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;
}
示例11: 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);
}
示例12: 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/>";
}
}
}
}
示例13: createDirectory
public function createDirectory($remoteDir)
{
// Require a connection and a login
$this->validateState();
$remoteDir = $this->buildAbsolutePath($remoteDir);
return @ftp_mkdir($this->ftpResource, $remoteDir);
}
示例14: preparePath
private function preparePath($subfolder)
{
if (!ftp_chdir($this->stream, $this->path)) {
$this->throwException('Cannot change directory to path "%s"', $this->path);
}
$p = $path = $this->path . $subfolder;
$folders = array();
while ($p != $this->path) {
if (!ftp_chdir($this->stream, $p)) {
$folders[] = basename($p);
$p = dirname($p);
} else {
krsort($folders);
foreach ($folders as $folder) {
$p .= '/' . $folder;
if (!ftp_mkdir($this->stream, $p)) {
$this->throwException('Cannot create path "%s"', $p);
}
ftp_chmod($this->stream, 0777, $p);
}
break;
}
}
ftp_chdir($this->stream, $path);
}
示例15: mmkdir
function mmkdir($directory)
{
if (!$this->conn_id) {
return false;
}
return @ftp_mkdir($this->conn_id, $directory);
}