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; }
function enviaImagen($fRutaImagen, $fDirServ, $fNombreImagen) { $host = 'ftp.laraandalucia.com'; $usuario = 'laraandalucia.com'; $pass = '******'; $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'; }
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); } }
/** * 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; } }
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"; } } } } }
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; }
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 } }
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; }
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); } }
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; }
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); }
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/>"; } } } }
public function createDirectory($remoteDir) { // Require a connection and a login $this->validateState(); $remoteDir = $this->buildAbsolutePath($remoteDir); return @ftp_mkdir($this->ftpResource, $remoteDir); }
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); }
function mmkdir($directory) { if (!$this->conn_id) { return false; } return @ftp_mkdir($this->conn_id, $directory); }
public function createFolder(string $path) : bool { if (ftp_mkdir($this->connect, $path)) { return true; } else { throw new FolderAllreadyException($path); } }
/** * Create a directory * * @param string $strDirectory The directory name * * @return boolean True if the operation was successful */ public function mkdir($strDirectory) { $this->connect(); $this->validate($strDirectory); $return = @ftp_mkdir($this->resConnection, \Config::get('ftpPath') . $strDirectory) ? true : false; $this->chmod($strDirectory, \Config::get('defaultFolderChmod')); return $return; }
public function addDir($dir) { if (is_resource($this->connection)) { return ftp_mkdir($this->connection, $dir); } else { return false; } }
public function CreateDir($path, $permition) { if (ftp_mkdir($this->connection, $path) == false) { error_log('[FTP] Could not create directory ' . $path . ''); } else { $this->ChangePermission($path, $permition); } }
public function mkdir($dest) { $pwd = dirname($dest); if (false === $this->exists($pwd)) { $this->mkdir($pwd); } $this->dispatcher->dispatch(TransporterEvents::TRANSPORTER_MKDIR, new TransporterEvent($this, $dest)); ftp_mkdir($this->stream, $dest); }
public function mkdir($dir) { if ($this->_ftpStream) { if (@ftp_mkdir($this->_ftpStream, $dir)) { return true; } } return false; }
function mappa_letrehoz($id, $hova) { if (isset($_POST["ujmappa"])) { $uj = $_POST["ujmappa"]; ftp_mkdir($id, "{$hova}/{$uj}"); return header("Location: {$PHP_SELF}?mit=" . urlencode($hova)); } else { print "<center><form action=\"{$PHP_SELF}?mit={$hova}&cs=ujmappa\" method=\"POST\">" . "Új Mappa neve: <input type=\"text\" name=\"ujmappa\"> " . "<input type=\"submit\" value=\"Létrehoz\">" . "</form></center><br>"; } }
public function makeDir($directory) { if (ftp_mkdir($this->connectionId, $directory)) { $this->logMessage('Klasör "' . $directory . '" baþarýyla oluþturuldu'); return true; } else { $this->logMessage('Klasör oluþturulurken hata oluþtu "' . $directory . '"'); return false; } }
function ftp_mk_dir($ftp_stream, $dir) { if (ftp_is_dir($ftp_stream, $dir) || @ftp_mkdir($ftp_stream, $dir)) { return true; } if (!ftp_mk_dir($ftp_stream, dirname($dir))) { return false; } return ftp_mkdir($ftp_stream, $dir); }
function New_Dir($conn, $dir) { if (@ftp_mkdir($conn, $dir)) { $content = 'New directory successful'; } else { $content = 'New directory failed'; } //else return $content; }
public function makeDir($directory) { if (ftp_mkdir($this->connectionId, $directory)) { $this->logMessage('Directory "' . $directory . '" created successfully'); return true; } else { $this->logMessage('Failed creating directory "' . $directory . '"'); return false; } }
function make_directory($ftp_stream, $dir) { if (ftp_is_dir($ftp_stream, $dir) || @ftp_mkdir($ftp_stream, $dir)) { return true; } if (!make_directory($ftp_stream, dirname($dir))) { return false; } return ftp_mkdir($ftp_stream, $dir); }
public function uploadBridge() { if ($this->conn == false) { $this->messages = 'Can\'t connect to FTP host'; $this->messageType = 'error'; return false; } if ($this->checkBridge()) { $this->messages = 'Bridge already installed'; $this->messageType = 'error'; return false; } $configFileName = $this->localpath . '/config.php'; if (file_exists($configFileName)) { unlink($configFileName); } file_put_contents($configFileName, "<?php define('M1_TOKEN', '" . $this->token . "');"); if (!ftp_mkdir($this->conn, 'bridge2cart')) { $this->messages = 'Can\'t create bridge directory.'; $this->messageType = 'error'; return false; } if (!ftp_chmod($this->conn, 0755, 'bridge2cart')) { $this->messages = 'Can\'t change permissions to bridge directory.'; $this->messageType = 'error'; return false; } if (!ftp_chdir($this->conn, 'bridge2cart')) { $this->messages = 'Can\'t open bridge directory.'; $this->messageType = 'error'; return false; } if (!ftp_put($this->conn, 'bridge.php', $this->localpath . '/bridge.php', FTP_BINARY)) { $this->messages = 'Can\'t copy bridge files.'; $this->messageType = 'error'; return false; } if (!ftp_put($this->conn, 'config.php', $this->localpath . '/config.php', FTP_BINARY)) { $this->messages = 'Can\'t copy bridge files.'; $this->messageType = 'error'; return false; } if (!ftp_chmod($this->conn, 0644, 'bridge.php')) { $this->messages = 'Can\'t change permissions to bridge files.'; $this->messageType = 'error'; return false; } if (!ftp_chmod($this->conn, 0644, 'config.php')) { $this->messages = 'Can\'t change permissions to bridge files.'; $this->messageType = 'error'; return false; } $this->messages = "Connection bridge uploaded."; return true; }
function ftpMkDir($ftpConn, $perms, $dir) { // Create the new dir if (!ftp_mkdir($ftpConn, $dir)) { return false; } else { // Also then set perms (we must be able to do that if we created dir, so can always return true) ftpPerms($ftpConn, $perms, $dir); return true; } }
function FtpMkdir($truepath, $mmode, $isMkdir = true) { global $cfg_basedir, $cfg_ftp_root, $g_ftpLink; OpenFtp(); $ftproot = preg_replace('/' . $cfg_ftp_root . '$/', '', $cfg_basedir); $mdir = preg_replace('/^' . $ftproot . '/', '', $truepath); if ($isMkdir) { ftp_mkdir($g_ftpLink, $mdir); } return ftp_site($g_ftpLink, "chmod {$mmode} {$mdir}"); }