本文整理汇总了PHP中ftp_size函数的典型用法代码示例。如果您正苦于以下问题:PHP ftp_size函数的具体用法?PHP ftp_size怎么用?PHP ftp_size使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ftp_size函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: clean
/**
* @param string $file
*/
private function clean($file)
{
if (ftp_size($this->connection, $file) == -1) {
$result = ftp_nlist($this->connection, $file);
foreach ($result as $childFile) {
$this->clean($childFile);
}
ftp_rmdir($this->connection, $file);
} else {
ftp_delete($this->connection, $file);
}
}
开发者ID:LibraryOfLawrence,项目名称:pagekit,代码行数:15,代码来源:FtpTestCase.php
示例2: fileSize
public function fileSize(string $path, string $type = 'b', int $decimal = 2) : float
{
$size = 0;
$extension = extension($path);
if (!empty($extension)) {
$size = ftp_size($this->connect, $path);
} else {
if ($this->files($path)) {
foreach ($this->files($path) as $val) {
$size += ftp_size($this->connect, $path . "/" . $val);
}
$size += ftp_size($this->connect, $path);
} else {
$size += ftp_size($this->connect, $path);
}
}
if ($type === "b") {
return $size;
}
if ($type === "kb") {
return round($size / 1024, $decimal);
}
if ($type === "mb") {
return round($size / (1024 * 1024), $decimal);
}
if ($type === "gb") {
return round($size / (1024 * 1024 * 1024), $decimal);
}
}
开发者ID:znframework,项目名称:znframework,代码行数:29,代码来源:Info.php
示例3: size
/**
* {@inheritdoc}
*/
public function size(BucketInterface $bucket, $name)
{
if (($size = ftp_size($this->connection, $this->getPath($bucket, $name))) != -1) {
return $size;
}
return false;
}
开发者ID:tuneyourserver,项目名称:components,代码行数:10,代码来源:FtpServer.php
示例4: downloadToTemp
public function downloadToTemp($pathAndFile, $startAt = 0, $files = false)
{
$pathAndFile = $this->removeSlashes($pathAndFile);
if (is_array($files)) {
$this->tempHandle = array();
foreach ($files as $file) {
$arrayCombined = $this->removeSlashes($pathAndFile . '/' . $file);
$fileSize = @ftp_size($this->ftpConnection, $arrayCombined);
if ($fileSize != -1) {
$this->tempHandle[$file] = tmpfile();
@ftp_fget($this->ftpConnection, $this->tempHandle[$file], $arrayCombined, FTP_BINARY, 0);
fseek($this->tempHandle[$file], 0);
}
}
} else {
$fileSize = @ftp_size($this->ftpConnection, $pathAndFile);
if ($fileSize != -1) {
$startAtSize = ($startAt != 0 and $fileSize > $startAt) ? $fileSize - $startAt : 0;
$this->tempHandle = tmpfile();
$download = @ftp_fget($this->ftpConnection, $this->tempHandle, $pathAndFile, FTP_BINARY, $startAtSize);
fseek($this->tempHandle, 0);
if ($download) {
return true;
}
}
}
return false;
}
开发者ID:Eun,项目名称:developer,代码行数:28,代码来源:class_ftp.php
示例5: build_content
function build_content($ftp, $dir)
{
$content_array = array();
$dirs_array = array();
$files_array = array();
$files = ftp_nlist($ftp, $dir);
foreach ($files as $filename) {
$filename = explode('/', $filename);
$filename = $filename[count($filename) - 1];
if ($filename == '.' || $filename == '..') {
continue;
}
$fullname = $filename;
if ($dir != '') {
$fullname = $dir . '/' . $fullname;
}
$filename = utf8_encode($filename);
if (ftp_size($ftp, $fullname) == -1) {
$fullname = utf8_encode($fullname);
$dirs_array[] = array('name' => $filename, 'file' => $fullname, 'is_folder' => 'true');
} else {
$fullname = utf8_encode($fullname);
$files_array[] = array('name' => $filename, 'file' => $fullname, 'icon' => get_icon($filename));
}
}
usort($dirs_array, 'cmp');
usort($files_array, 'cmp');
$content_array = array_merge($dirs_array, $files_array);
return $content_array;
}
开发者ID:hoksi,项目名称:mangolight-editor,代码行数:30,代码来源:list.php
示例6: msize
function msize($remote_file)
{
if (!$this->conn_id) {
return false;
}
return @ftp_size($this->conn_id, $remote_file);
}
开发者ID:polarlight1989,项目名称:08cms,代码行数:7,代码来源:ftp.fun.php
示例7: _getFileInfo
function _getFileInfo($path)
{
//$curdir = ftp_pwd($this->_link);
//$isDir = @ftp_chdir($this->_link, $path);
//ftp_chdir($this->_link, $curdir);
$size = ftp_size($this->_link, $path);
return array(name => basename($path), modified => ftp_mdtm($this->_link, $path), size => $size, type => $size == -1 ? "text/directory" : "text/plain");
}
开发者ID:Rudi9719,项目名称:lucid,代码行数:8,代码来源:Ftp.php
示例8: is_exists
function is_exists($file)
{
$res = ftp_size($this->con, $file);
if ($res != -1) {
return true;
} else {
return false;
}
}
开发者ID:kertkulp,项目名称:php-ruhmatoo-projekt,代码行数:9,代码来源:ftp_func.php
示例9: getSize
/**
* Gets file size
*
* @throws cFTP_Exception
*
* @return int File size
*/
public function getSize()
{
$res = @ftp_size($this->handle, $this->name);
if( $res == -1 )
throw new cFTP_Exception( "Could not get file size", 32 );
return $res;
}
开发者ID:robik,项目名称:cFTP,代码行数:16,代码来源:File.php
示例10: delete
public function delete($file)
{
if (ftp_size($this->connection, $file) != -1) {
$delete = ftp_delete($this->connection, $file);
if ($delete) {
} else {
}
}
return $this;
}
开发者ID:natgeo,项目名称:kids-myshot,代码行数:10,代码来源:ftp.php
示例11: remotefsize
/**
* Remote file size function for streams that don't support it
*
* @param string $url TODO Add text
*
* @return mixed
*
* @see http://www.php.net/manual/en/function.filesize.php#71098
* @since 11.1
*/
function remotefsize($url)
{
$sch = parse_url($url, PHP_URL_SCHEME);
if ($sch != 'http' && $sch != 'https' && $sch != 'ftp' && $sch != 'ftps') {
return false;
}
if ($sch == 'http' || $sch == 'https') {
$headers = get_headers($url, 1);
if (!array_key_exists('Content-Length', $headers)) {
return false;
}
return $headers['Content-Length'];
}
if ($sch == 'ftp' || $sch == 'ftps') {
$server = parse_url($url, PHP_URL_HOST);
$port = parse_url($url, PHP_URL_PORT);
$path = parse_url($url, PHP_URL_PATH);
$user = parse_url($url, PHP_URL_USER);
$pass = parse_url($url, PHP_URL_PASS);
if (!$server || !$path) {
return false;
}
if (!$port) {
$port = 21;
}
if (!$user) {
$user = 'anonymous';
}
if (!$pass) {
$pass = '';
}
switch ($sch) {
case 'ftp':
$ftpid = ftp_connect($server, $port);
break;
case 'ftps':
$ftpid = ftp_ssl_connect($server, $port);
break;
}
if (!$ftpid) {
return false;
}
$login = ftp_login($ftpid, $user, $pass);
if (!$login) {
return false;
}
$ftpsize = ftp_size($ftpid, $path);
ftp_close($ftpid);
if ($ftpsize == -1) {
return false;
}
return $ftpsize;
}
}
开发者ID:Radek-Suski,项目名称:joomla-platform,代码行数:64,代码来源:helper.php
示例12: put
public function put($local_file_path, $remote_file_path, $mode = FTP_BINARY, $resume = false, $updraftplus = false)
{
$file_size = filesize($local_file_path);
$existing_size = 0;
if ($resume) {
$existing_size = ftp_size($this->conn_id, $remote_file_path);
if ($existing_size <= 0) {
$resume = false;
$existing_size = 0;
} else {
if (is_a($updraftplus, 'UpdraftPlus')) {
$updraftplus->log("File already exists at remote site: size {$existing_size}. Will attempt resumption.");
}
if ($existing_size >= $file_size) {
if (is_a($updraftplus, 'UpdraftPlus')) {
$updraftplus->log("File is apparently already completely uploaded");
}
return true;
}
}
}
// From here on, $file_size is only used for logging calculations. We want to avoid divsion by zero.
$file_size = max($file_size, 1);
if (!($fh = fopen($local_file_path, 'rb'))) {
return false;
}
if ($existing_size) {
fseek($fh, $existing_size);
}
$ret = ftp_nb_fput($this->conn_id, $remote_file_path, $fh, FTP_BINARY, $existing_size);
// $existing_size can now be re-purposed
while ($ret == FTP_MOREDATA) {
if (is_a($updraftplus, 'UpdraftPlus')) {
$new_size = ftell($fh);
if ($new_size - $existing_size > 524288) {
$existing_size = $new_size;
$percent = round(100 * $new_size / $file_size, 1);
$updraftplus->record_uploaded_chunk($percent, '', $local_file_path);
}
}
// Continue upload
$ret = ftp_nb_continue($this->conn_id);
}
fclose($fh);
if ($ret != FTP_FINISHED) {
if (is_a($updraftplus, 'UpdraftPlus')) {
$updraftplus->log("FTP upload: error ({$ret})");
}
return false;
}
return true;
}
开发者ID:brandmobility,项目名称:kikbak,代码行数:52,代码来源:ftp.class.php
示例13: browse_file
function browse_file($action = null, $id = null)
{
if ($this->input->is_ajax_request()) {
$ftp_server = trim($this->input->post('server'));
$ftp_user = trim($this->input->post('username'));
$ftp_password = trim($this->input->post('password'));
$port = trim($this->input->post('port'));
$dir = trim($this->input->post('dir'));
$sftp = $this->input->post('SFTP');
if ($dir === "." || $dir === "./" || $dir === "//" || $dir === "../" || $dir === "/./" || $dir === "") {
$dir = "/";
}
if ($action === "index") {
$allowed_extentions = array("htm", "html", "php");
} else {
if ($action === "img") {
$allowed_extentions = array("jpg", "jpeg", "gif", "png", "bmp", "psd", "pxd");
} else {
if ($action === "docs") {
$allowed_extentions = array("txt", "pdf", "doc", "docx", "log", "rtf", "ppt", "pptx", "swf");
}
}
}
$this->_open_connection($ftp_server, $ftp_user, $ftp_password, $port, $sftp);
$ftp_nlist = $this->ftp->list_files($dir);
sort($ftp_nlist);
$output = '<ul class="jqueryFileTree" style="display: none;">';
foreach ($ftp_nlist as $folder) {
//1. Size is '-1' => directory
if (@ftp_size($this->ftp->conn_id, $dir . $folder) == '-1' && $folder !== "." && $folder !== "..") {
//output as [ directory ]
$output .= '<li class="directory collapsed"><a href="' . $folder . '" rel="' . $dir . htmlentities($folder) . '/' . '">' . htmlentities($folder) . '</a></li>';
}
}
foreach ($ftp_nlist as $file) {
//2. Size is not '-1' => file
if (!(@ftp_size($this->ftp->conn_id, $dir . $file) == '-1')) {
//output as file
$ext = preg_replace('/^.*\\./', '', $file);
if (in_array($ext, $allowed_extentions)) {
$output .= '<li class="file ext_' . $ext . '"><a href="' . htmlentities($file) . '" rel="' . $dir . htmlentities($file) . '">' . htmlentities($file) . '</a></li>';
}
}
}
echo $output . '</ul>';
$this->ftp->close();
} else {
show_404();
}
}
开发者ID:braxtondiggs,项目名称:Clefable,代码行数:50,代码来源:ftp.php
示例14: getFileList
protected function getFileList($connection, $path) {
@ftp_chdir($connection, $path);
$list = ftp_nlist($connection, ".");
$files = array();
if ($list) {
foreach ($list as $filename) {
$fullpath = strlen($path) < 1 ? $filename : $path . "/" . $filename;
$size = ftp_size($connection, $filename);
$files[] = new CloudFile($filename, $fullpath, $size < 0, $size, $this->getName());
}
}
ftp_close($connection);
return $files;
}
开发者ID:nikosv,项目名称:openeclass,代码行数:14,代码来源:ftp.php
示例15: getFileList
function getFileList(&$errors = array())
{
$filelist = array();
if ($this->direction == 'IN') {
switch (strtoupper($this->transfer_type)) {
case 'FTP':
$conn = $this->ftpConnection($errors);
if (!$conn || count($errors) > 0) {
$errors[] = 'Error connecting to remote site to get file list';
return false;
}
$external_list = ftp_nlist($conn, ".");
foreach ($external_list as $key => $file) {
if (ftp_size($conn, $file) == -1 || $file == '.' || $file == '..') {
unset($external_list[$key]);
}
}
foreach ($external_list as $id) {
$filelist[$id] = $this->file_prefix . $id . (!empty($this->file_extension) ? '.' . strtolower($this->file_extension) : '');
}
asort($filelist);
ftp_close($conn);
break;
case 'LOCAL':
$filepath = $this->get_file_path();
$handle = opendir($filepath);
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != ".." && !is_dir($filepath . DIRECTORY_SEPARATOR . $file) && substr($file, 0, strlen($this->file_prefix)) == $this->file_prefix && substr($file, -strlen($this->file_extension)) == $this->file_extension) {
$filelist[$file] = $file;
}
}
closedir($handle);
break;
default:
$errors[] = $this->transfer_type . ' transfer type not supported';
}
return $filelist;
}
// Direction is not 'IN'
$extractlist = array();
if (!empty($this->process_model) && !empty($this->process_function) && method_exists($this->process_model, $this->process_function)) {
$model = new $this->process_model();
$extractlist = call_user_func(array($model, $this->process_function), $this->id);
foreach ($extractlist as $key => $value) {
$extractlist[$key] = $this->file_prefix . $value . (!empty($this->file_extension) ? '.' . strtolower($this->file_extension) : '');
}
}
return $extractlist;
}
开发者ID:uzerpllp,项目名称:uzerp,代码行数:49,代码来源:EdiInterface.php
示例16: image_dir_scan
public function image_dir_scan($dir, $basedir)
{
$data = array();
$dir = $basedir . $dir;
$files = ftp_rawlist($this->link, $dir);
foreach ($files as $v) {
$file = ltrim(strrchr($v, ' '), ' ');
$path = "{$dir}/{$file}";
if (preg_match('/^-/', $v)) {
if (preg_match('/^[a-zA-z0-9]+\\.(gif|png|jpg|jpeg)$/', $file)) {
//遍历目录设置
array_push($data, array(str_replace($basedir, '', $path), ftp_size($this->link, $path)));
}
}
}
return $data;
}
开发者ID:lz1988,项目名称:stourwebcms,代码行数:17,代码来源:remote.php
示例17: doFileExists
protected function doFileExists($remote_file)
{
// check if exists as file
if (ftp_size($this->getConnection(), $remote_file) != -1) {
return true;
// file exists
}
// check if exists as dir
$pwd = ftp_pwd($this->getConnection());
if (ftp_chdir($this->getConnection(), $remote_file)) {
ftp_chdir($this->getConnection(), $pwd);
return true;
// dir exists
}
// does not exist
return false;
}
开发者ID:richhl,项目名称:kalturaCE,代码行数:17,代码来源:ftpMgr.class.php
示例18: remoteFileCmp
/**
* @access public
* Affiche les données du fichier en cours de téléchargement (comparaison local et distante)
* @param $server_file
* @return string
*/
public function remoteFileCmp($server_file)
{
// Récupération de la taille du fichier $file
$res = ftp_size($this->ftpConnect(), $server_file);
if ($res != -1) {
//echo 'La taille du fichier '.self::SERVERFILE.' est de '.$res.' octets sur le serveur<br />';
$getFileSize = $res;
} else {
//echo "Impossible de récupérer la taille du fichier";
$getFileSize = '';
}
/*On ferme la connexion FTP*/
ftp_close($this->ftpConnect());
$comp = $getFileSize;
return $comp;
//print 'Taille du fichier local : '.filesize(self::LOCALFILE).' octets';
}
开发者ID:magix-cms,项目名称:magixcms-3,代码行数:23,代码来源:ftp.php
示例19: rmAll
function rmAll($dst_dir, $debug = 0)
{
if (!$dst_dir) {
return false;
exit;
}
$dst_dir = preg_replace("/\\/\$/", "", $dst_dir);
// remove trailing slash
$ar_files = ftp_nlist($this->conn_id, $dst_dir);
if (is_array($ar_files)) {
// makes sure there are files
if (count($ar_files) == 1) {
// if its only a file
return ftp_delete($this->conn_id, $ar_files[0]);
} else {
foreach ($ar_files as $st_file) {
// for each file
if ($st_file == "." || $st_file == "..") {
continue 1;
}
$fl_file = "{$dst_dir}/{$st_file}";
$ftp_size = ftp_size($this->conn_id, $fl_file);
if ($ftp_size == -1) {
// check if it is a directory
$this->rmAll($fl_file);
// if so, use recursion
} else {
if ($debug) {
echo "File: {$fl_file} | {$ftp_size}\n";
} else {
ftp_delete($this->conn_id, $fl_file);
}
// if not, delete the file
}
}
}
}
if ($debug) {
echo "Dir: {$dst_dir} \n";
} elseif (count($ar_files) != 1) {
echo @ftp_rmdir($this->conn_id, $dst_dir) ? "{$dst_dir} deleted!\n" : "Can't remove {$dst_dir}: No such file or directory";
}
// delete empty directories
}
开发者ID:hukumonline,项目名称:admin,代码行数:44,代码来源:Ftp.php
示例20: isFileExist
public function isFileExist($fileName)
{
try {
$conn_id = $this->CI->util->connectFTPServer('azure');
if ($conn_id) {
$file = $this->dataFolder . $fileName . '.csv';
$res = ftp_size($conn_id, $file);
$this->CI->util->closeFTPConnection($conn_id);
return $res != -1;
} else {
return false;
}
} catch (Exception $e) {
echo "Error: <br>";
$this->CI->util->echoObject($e);
return false;
} catch (ErrorException $e) {
echo "Error: <br>";
$this->CI->util->echoObject($e);
return false;
}
}
开发者ID:nignjatov,项目名称:TaxiDev,代码行数:22,代码来源:arrayToCsv.php
注:本文中的ftp_size函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论