当前位置: 首页>>代码示例>>PHP>>正文


PHP filesize函数代码示例

本文整理汇总了PHP中filesize函数的典型用法代码示例。如果您正苦于以下问题:PHP filesize函数的具体用法?PHP filesize怎么用?PHP filesize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了filesize函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testFileRetrieving

 /**
  * Invokes system_retrieve_file() in several scenarios.
  */
 function testFileRetrieving()
 {
     // Test 404 handling by trying to fetch a randomly named file.
     drupal_mkdir($sourcedir = 'public://' . $this->randomMachineName());
     $filename = 'Файл для тестирования ' . $this->randomMachineName();
     $url = file_create_url($sourcedir . '/' . $filename);
     $retrieved_file = system_retrieve_file($url);
     $this->assertFalse($retrieved_file, 'Non-existent file not fetched.');
     // Actually create that file, download it via HTTP and test the returned path.
     file_put_contents($sourcedir . '/' . $filename, 'testing');
     $retrieved_file = system_retrieve_file($url);
     // URLs could not contains characters outside the ASCII set so $filename
     // has to be encoded.
     $encoded_filename = rawurlencode($filename);
     $this->assertEqual($retrieved_file, 'public://' . $encoded_filename, 'Sane path for downloaded file returned (public:// scheme).');
     $this->assertTrue(is_file($retrieved_file), 'Downloaded file does exist (public:// scheme).');
     $this->assertEqual(filesize($retrieved_file), 7, 'File size of downloaded file is correct (public:// scheme).');
     file_unmanaged_delete($retrieved_file);
     // Test downloading file to a different location.
     drupal_mkdir($targetdir = 'temporary://' . $this->randomMachineName());
     $retrieved_file = system_retrieve_file($url, $targetdir);
     $this->assertEqual($retrieved_file, "{$targetdir}/{$encoded_filename}", 'Sane path for downloaded file returned (temporary:// scheme).');
     $this->assertTrue(is_file($retrieved_file), 'Downloaded file does exist (temporary:// scheme).');
     $this->assertEqual(filesize($retrieved_file), 7, 'File size of downloaded file is correct (temporary:// scheme).');
     file_unmanaged_delete($retrieved_file);
     file_unmanaged_delete_recursive($sourcedir);
     file_unmanaged_delete_recursive($targetdir);
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:31,代码来源:RetrieveFileTest.php

示例2: openImage

 private function openImage($file)
 {
     // *** Get extension
     $extension = strtolower(strrchr($file, '.'));
     $file_size = @filesize($file) / 1024 / 1024;
     // magic number convert bytes to mb
     $image_size_limit = 0.5;
     // sorry for the magic numbering... can't get a good read on how to programatically fix this.
     // if we're about to try to load a massive image...
     // don't
     if ($file_size >= $image_size_limit || $file_size == 0) {
         return false;
     }
     switch ($extension) {
         case '.jpg':
         case '.jpeg':
             $img = imagecreatefromjpeg($file);
             break;
         case '.gif':
             $img = @imagecreatefromgif($file);
             break;
         case '.png':
             $img = @imagecreatefrompng($file);
             break;
         default:
             $img = false;
             break;
     }
     return $img;
 }
开发者ID:lytranuit,项目名称:wordpress,代码行数:30,代码来源:image-resize-writer.php

示例3: buildJavascriptConfiguration

 /**
  * Return JS configuration of the htmlArea plugins registered by the extension
  *
  * @return string JS configuration for registered plugins
  */
 public function buildJavascriptConfiguration()
 {
     $schema = array('types' => array(), 'properties' => array());
     // Parse configured schemas
     if (is_array($this->configuration['thisConfig']['schema.']) && is_array($this->configuration['thisConfig']['schema.']['sources.'])) {
         foreach ($this->configuration['thisConfig']['schema.']['sources.'] as $source) {
             $fileName = trim($source);
             $absolutePath = GeneralUtility::getFileAbsFileName($fileName);
             // Fallback to default schema file if configured file does not exists or is of zero size
             if (!$fileName || !file_exists($absolutePath) || !filesize($absolutePath)) {
                 $fileName = 'EXT:' . $this->extensionKey . '/Resources/Public/Rdf/MicrodataSchema/SchemaOrgAll.rdf';
             }
             $fileName = $this->getFullFileName($fileName);
             $rdf = file_get_contents($fileName);
             if ($rdf) {
                 $this->parseSchema($rdf, $schema);
             }
         }
     }
     uasort($schema['types'], array($this, 'compareLabels'));
     uasort($schema['properties'], array($this, 'compareLabels'));
     // Insert no type and no property entries
     $languageService = $this->getLanguageService();
     $noSchema = $languageService->sL('LLL:EXT:rtehtmlarea/Resources/Private/Language/Plugins/MicrodataSchema/locallang.xlf:No type');
     $noProperty = $languageService->sL('LLL:EXT:rtehtmlarea/Resources/Private/Language/Plugins/MicrodataSchema/locallang.xlf:No property');
     array_unshift($schema['types'], array('name' => 'none', 'label' => $noSchema));
     array_unshift($schema['properties'], array('name' => 'none', 'label' => $noProperty));
     // Store json encoded array in temporary file
     return 'RTEarea[editornumber].schemaUrl = "' . $this->writeTemporaryFile('schema_' . $this->configuration['language'], 'js', json_encode($schema)) . '";';
 }
开发者ID:dachcom-digital,项目名称:TYPO3.CMS,代码行数:35,代码来源:MicroDataSchema.php

示例4: fsize

function fsize($file)
{
    // filesize will only return the lower 32 bits of
    // the file's size! Make it unsigned.
    $fmod = filesize($file);
    if ($fmod < 0) {
        $fmod += 2.0 * (PHP_INT_MAX + 1);
    }
    // find the upper 32 bits
    $i = 0;
    $myfile = fopen($file, "r");
    // feof has undefined behaviour for big files.
    // after we hit the eof with fseek,
    // fread may not be able to detect the eof,
    // but it also can't read bytes, so use it as an
    // indicator.
    while (strlen(fread($myfile, 1)) === 1) {
        fseek($myfile, PHP_INT_MAX, SEEK_CUR);
        $i++;
    }
    fclose($myfile);
    // $i is a multiplier for PHP_INT_MAX byte blocks.
    // return to the last multiple of 4, as filesize has modulo of 4 GB (lower 32 bits)
    if ($i % 2 == 1) {
        $i--;
    }
    // add the lower 32 bit to our PHP_INT_MAX multiplier
    return (double) $i * (PHP_INT_MAX + 1) + $fmod;
}
开发者ID:netor27,项目名称:UnovaPrivado,代码行数:29,代码来源:funcionesParaArchivos.php

示例5: dwld

 public function dwld()
 {
     $this->min();
     if (is_numeric($this->getParam("id"))) {
         $this->download->newDownload();
         if ($this->download->getIsLocal()) {
             $url = OWEB_DIR_DATA . "/downloads/" . $this->download->getUrl();
             header('Content-Description: File Transfer');
             header('Content-Type: application/octet-stream');
             header('Content-Disposition: attachment; filename="' . basename($url) . '";');
             readfile($url);
         } else {
             $url = OWEB_DIR_DATA . "/downloads/" . $this->download->getUrl();
             header("Content-Disposition: attachment; filename=" . basename($url));
             header("Content-Type: application/force-download");
             header("Content-Type: application/octet-stream");
             header("Content-Type: application/download");
             header("Content-Description: File Transfer");
             header("Content-Length: " . filesize($url));
             flush();
             // this doesn't really matter.
             $fp = fopen($url, "r");
             while (!feof($fp)) {
                 echo fread($fp, 65536);
                 flush();
                 // this is essential for large downloads
             }
             fclose($fp);
         }
     } else {
         throw new \Model\downloads\exception\DownloadCantBeFind("No Download ID given");
     }
 }
开发者ID:oliverde8,项目名称:oweb-framework,代码行数:33,代码来源:Download.php

示例6: fa_cache_avatar

function fa_cache_avatar($avatar, $id_or_email, $size, $default, $alt)
{
    $avatar = str_replace(array("www.gravatar.com", "0.gravatar.com", "1.gravatar.com", "2.gravatar.com"), "cn.gravatar.com", $avatar);
    $tmp = strpos($avatar, 'http');
    $url = get_avatar_url($id_or_email, $size);
    $url = str_replace(array("www.gravatar.com", "0.gravatar.com", "1.gravatar.com", "2.gravatar.com"), "cn.gravatar.com", $url);
    $avatar2x = get_avatar_url($id_or_email, $size * 2);
    $avatar2x = str_replace(array("www.gravatar.com", "0.gravatar.com", "1.gravatar.com", "2.gravatar.com"), "cn.gravatar.com", $avatar2x);
    $g = substr($avatar, $tmp, strpos($avatar, "'", $tmp) - $tmp);
    $tmp = strpos($g, 'avatar/') + 7;
    $f = substr($g, $tmp, strpos($g, "?", $tmp) - $tmp);
    $w = home_url();
    $e = ABSPATH . 'avatar/' . $size . '*' . $f . '.jpg';
    $e2x = ABSPATH . 'avatar/' . $size * 2 . '*' . $f . '.jpg';
    $t = 1209600;
    if ((!is_file($e) || time() - filemtime($e) > $t) && (!is_file($e2x) || time() - filemtime($e2x) > $t)) {
        copy(htmlspecialchars_decode($g), $e);
        copy(htmlspecialchars_decode($avatar2x), $e2x);
    } else {
        $avatar = $w . '/avatar/' . $size . '*' . $f . '.jpg';
        $avatar2x = $w . '/avatar/' . $size * 2 . '*' . $f . '.jpg';
        if (filesize($e) < 1000) {
            copy($w . '/avatar/default.jpg', $e);
        }
        if (filesize($e2x) < 1000) {
            copy($w . '/avatar/default.jpg', $e2x);
        }
        $avatar = "<img alt='{$alt}' src='{$avatar}' srcset='{$avatar2x}' class='avatar avatar-{$size} photo' height='{$size}' width='{$size}' />";
    }
    return $avatar;
}
开发者ID:wangshijun101,项目名称:morketing.cn,代码行数:31,代码来源:avatar.php

示例7: cacheFiles

    /**
     * The main function in the class
     *
     * @return	string		HTML content
     */
    function cacheFiles()
    {
        $content = '';
        // CURRENT:
        $content .= '<strong>1: The current cache files:</strong>' . Tx_Extdeveval_Compatibility::viewArray(t3lib_extMgm::currentCacheFiles());
        // REMOVING?
        if (t3lib_div::_GP('REMOVE_temp_CACHED')) {
            $number = $this->removeCacheFiles();
            $content .= '<hr /><p><strong>2: Tried to remove ' . $number . ' cache files.</strong></p>';
        }
        if (t3lib_div::_GP('REMOVE_temp_CACHED_ALL')) {
            $content .= '<hr /><p><strong>2: Removing ALL "temp_CACHED_*" files:</strong></p>' . $this->removeALLtempCachedFiles();
        }
        $files = t3lib_div::getFilesInDir(PATH_typo3conf, 'php');
        $tRows = array();
        foreach ($files as $f) {
            $tRows[] = '<tr>
				<td>' . htmlspecialchars($f) . '</td>
				<td>' . t3lib_div::formatSize(filesize(PATH_typo3conf . $f)) . '</td>
			</tr>';
        }
        $content .= '<br /><strong>3: PHP files (now) in "' . PATH_typo3conf . '":</strong><br />
		<table border="1">' . implode('', $tRows) . '</table>

		<input type="submit" name="REMOVE_temp_CACHED" value="REMOVE current temp_CACHED files" />
		<input type="submit" name="REMOVE_temp_CACHED_ALL" value="REMOVE ALL temp_CACHED_* files" />
		<input type="submit" name="_" value="Refresh" />
		';
        return $content;
    }
开发者ID:raimundlandig,项目名称:winkel.de-DEV,代码行数:35,代码来源:class.tx_extdeveval_cachefiles.php

示例8: getDirectorySize

function getDirectorySize($path)
{
    $totalsize = 0;
    $totalcount = 0;
    $dircount = 0;
    if ($handle = opendir($path)) {
        while (false !== ($file = readdir($handle))) {
            $nextpath = $path . '/' . $file;
            if ($file != '.' && $file != '..' && !is_link($nextpath)) {
                if (is_dir($nextpath)) {
                    $dircount++;
                    $result = getDirectorySize($nextpath);
                    $totalsize += $result['size'];
                    $totalcount += $result['count'];
                    $dircount += $result['dircount'];
                } elseif (is_file($nextpath)) {
                    $totalsize += filesize($nextpath);
                    $totalcount++;
                }
            }
        }
    }
    closedir($handle);
    $total['size'] = $totalsize;
    $total['count'] = $totalcount;
    $total['dircount'] = $dircount;
    return $total;
}
开发者ID:phprocks,项目名称:cadastro,代码行数:28,代码来源:administration.php

示例9: display

 public function display($cachable = false, $urlparams = false)
 {
     JRequest::setVar('view', JRequest::getCmd('view', 'Orphans'));
     if (isset($_POST['_orphanaction']) && $_POST['_orphanaction'] == "zipIt") {
         $file = tempnam("tmp", "zip");
         $zip = new ZipArchive();
         $zip->open($file, ZipArchive::OVERWRITE);
         foreach ($_POST['tozip'] as $_file) {
             $zip->addFile(JPATH_ROOT . "/" . $_file, $_file);
         }
         $zip->close();
         header('Content-Type: application/zip');
         header('Content-Length: ' . filesize($file));
         header('Content-Disposition: attachment; filename="orphans.zip"');
         readfile($file);
         unlink($file);
         die;
     } else {
         if (isset($_POST['_orphanaction']) && $_POST['_orphanaction'] == "delete" && isset($_POST['_confirmAction'])) {
             foreach ($_POST['tozip'] as $_file) {
                 unlink(JPATH_ROOT . "/" . $_file);
             }
         }
     }
     // call parent behavior
     parent::display($cachable);
 }
开发者ID:james-Ballyhoo,项目名称:com_orphan,代码行数:27,代码来源:controller.php

示例10: size

 public function size() : int
 {
     if ($this->fileCount === 0) {
         return 0;
     }
     return filesize($this->pathToZip);
 }
开发者ID:spatie,项目名称:laravel-backup,代码行数:7,代码来源:Zip.php

示例11: getDocuments

 public function getDocuments($name)
 {
     if (!file_exists($this->_getFilePathName($name))) {
         return array();
     }
     $fp = fopen($this->_getFilePathName($name), 'r');
     $filesize = filesize($this->_getFilePathName($name));
     if ($filesize % MULTIINDEX_DOCUMENTBYTESIZE != 0) {
         throw new Exception('Filesize not correct index is corrupt!');
     }
     $ret = array();
     $count = 0;
     for ($i = 0; $i < $filesize / MULTIINDEX_DOCUMENTBYTESIZE; $i++) {
         $bindata1 = fread($fp, MULTIINDEX_DOCUMENTINTEGERBYTESIZE);
         $bindata2 = fread($fp, MULTIINDEX_DOCUMENTINTEGERBYTESIZE);
         $bindata3 = fread($fp, MULTIINDEX_DOCUMENTINTEGERBYTESIZE);
         $data1 = unpack('i', $bindata1);
         $data2 = unpack('i', $bindata2);
         $data3 = unpack('i', $bindata3);
         $ret[] = array($data1[1], $data2[1], $data3[1]);
         $count++;
         if ($count == MULTIINDEX_DOCUMENTRETURN) {
             break;
         }
     }
     fclose($fp);
     return $ret;
 }
开发者ID:thegeekajay,项目名称:search-engine,代码行数:28,代码来源:multifolderindex.class.php

示例12: writeFile

 /**
  * Uploads file to FTP server.
  * @return void
  */
 public function writeFile($local, $remote, callable $progress = NULL)
 {
     $size = max(filesize($local), 1);
     $retry = self::RETRIES;
     upload:
     $blocks = 0;
     do {
         if ($progress) {
             $progress(min($blocks * self::BLOCK_SIZE / $size, 100));
         }
         try {
             $ret = $blocks === 0 ? $this->ftp('nb_put', $remote, $local, FTP_BINARY) : $this->ftp('nb_continue');
         } catch (FtpException $e) {
             @ftp_close($this->connection);
             // intentionally @
             $this->connect();
             if (--$retry) {
                 goto upload;
             }
             throw new FtpException("Cannot upload file {$local}, number of retries exceeded. Error: {$e->getMessage()}");
         }
         $blocks++;
     } while ($ret === FTP_MOREDATA);
     if ($progress) {
         $progress(100);
     }
 }
开发者ID:hranicka,项目名称:dg-ftp-deployment,代码行数:31,代码来源:FtpServer.php

示例13: tree

 /**
  * 遍历目录内容
  * @param string $dirName 目录名
  * @param string $exts 扩展名
  * @param int $son 是否显示子目录
  * @param array $list
  * @return array
  */
 static function tree($dirName=null, $exts = '', $son = 0, $list = array()) {
     if(is_null($dirName))$dirName='.';
     $dirPath = self::dirPath($dirName);
     static $id = 0;
     if (is_array($exts))
         $exts = implode("|", $exts);
     foreach (glob($dirPath . '*') as $v) {
         $id++;
         if (is_dir($v) || !$exts || preg_match("/\.($exts)/i", $v)) {
             $list [$id] ['name'] = basename($v);
             $list [$id] ['path'] = str_replace("\\", "/", realpath($v));
             $list [$id] ['type'] = filetype($v);
             $list [$id] ['filemtime'] = filemtime($v);
             $list [$id] ['fileatime'] = fileatime($v);
             $list [$id] ['size'] = filesize($v);
             $list [$id] ['iswrite'] = is_writeable($v) ? 1 : 0;
             $list [$id] ['isread'] = is_readable($v) ? 1 : 0;
         }
         if ($son) {
             if (is_dir($v)) {
                 $list = self::tree($v, $exts, $son = 1, $list);
             }
         }
     }
     return $list;
 }
开发者ID:happyun,项目名称:tuan,代码行数:34,代码来源:Dir.class.php

示例14: download

 public static function download($fullPath)
 {
     if ($fd = fopen($fullPath, 'r')) {
         $fsize = filesize($fullPath);
         $path_parts = pathinfo($fullPath);
         $ext = strtolower($path_parts['extension']);
         switch ($ext) {
             case 'pdf':
                 header('Content-type: application/pdf');
                 // add here more headers for diff. extensions
                 header('Content-Disposition: attachment; filename="' . $path_parts['basename'] . '"');
                 // use 'attachment' to force a download
                 break;
             default:
                 header('Content-type: application/octet-stream');
                 header('Content-Disposition: filename="' . $path_parts['basename'] . '"');
                 break;
         }
         header("Content-length: {$fsize}");
         header('Cache-control: private');
         //use this to open files directly
         while (!feof($fd)) {
             $buffer = fread($fd, 2048);
             echo $buffer;
         }
     }
     fclose($fd);
 }
开发者ID:speedwork,项目名称:util,代码行数:28,代码来源:Utility.php

示例15: final_extract_install

function final_extract_install()
{
    global $CONFIG, $lang_plugin_final_extract, $lang_plugin_final_extract_config, $thisplugin;
    require 'plugins/final_extract/configuration.php';
    require 'include/sql_parse.php';
    if (!isset($CONFIG['fex_enable'])) {
        $query = "INSERT INTO " . $CONFIG['TABLE_CONFIG'] . " VALUES ('fex_enable', '1');";
        cpg_db_query($query);
        // create table
        $db_schema = $thisplugin->fullpath . '/schema.sql';
        $sql_query = fread(fopen($db_schema, 'r'), filesize($db_schema));
        $sql_query = preg_replace('/CPG_/', $CONFIG['TABLE_PREFIX'], $sql_query);
        $sql_query = remove_remarks($sql_query);
        $sql_query = split_sql_file($sql_query, ';');
        foreach ($sql_query as $q) {
            cpg_db_query($q);
        }
        // Put default setting
        $db_schema = $thisplugin->fullpath . '/basic.sql';
        $sql_query = fread(fopen($db_schema, 'r'), filesize($db_schema));
        $sql_query = preg_replace('/CPG_/', $CONFIG['TABLE_PREFIX'], $sql_query);
        $sql_query = remove_remarks($sql_query);
        $sql_query = split_sql_file($sql_query, ';');
        foreach ($sql_query as $q) {
            cpg_db_query($q);
        }
    }
    return true;
}
开发者ID:phill104,项目名称:branches,代码行数:29,代码来源:codebase.php


注:本文中的filesize函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。