本文整理汇总了PHP中file类的典型用法代码示例。如果您正苦于以下问题:PHP file类的具体用法?PHP file怎么用?PHP file使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了file类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: uploadFile2
/**
* @ORM\PostPersist
*/
public function uploadFile2()
{
if (null === $this->file2) {
return;
} else {
$this->file2->move(__DIR__ . '/../../../app/uploads' . $this->getUploadDir(), $this->second_fichier);
unset($this->file2);
}
}
示例2: createAndWrite
function createAndWrite($file, $string)
{
$file_ins = new file();
if ($file_ins->createFile($file)) {
$file_ins->writeToFile($string);
return True;
} else {
return False;
}
}
示例3: upload
/**
* @ORM\PostPersist
*/
public function upload()
{
if (null === $this->file) {
return;
}
// if there is an error when moving the file, an exception will
// be automatically thrown by move(). This will properly prevent
// the entity from being persisted to the database on error
$this->file->move($this->getUploadRootDir(), $this->photo);
unset($this->file);
}
示例4: file_upload
function file_upload($files)
{
global $upload_path;
$objects = array();
foreach ($files as $file) {
if (!empty($file['name'])) {
$obj = new file();
$obj->upload($file);
$objects[] = $obj;
}
}
return $objects;
}
示例5: __destruct
public function __destruct()
{
flush();
if (!is_dir(ROOT . 'task')) {
return false;
}
if (AJAX) {
return false;
}
//ajax操作的时候不做计划任务
if (defined('CLOSETASK')) {
return false;
}
extract($this->info);
/** 分时计划任务 **/
$file = new file();
$db = new db();
$str = new str();
$time = time();
$today = $str->formatDate($time, 'Ymd');
for ($i_task = 1; $i_task <= 6; $i_task++) {
if ($time - intval(kc_config('task.update' . $i_task)) > 3600 * $i_task) {
$tasks = $file->getDir('task/' . $i_task . '/', 'php');
if (!empty($tasks)) {
foreach ($tasks as $k => $v) {
require ROOT . $k;
}
}
unset($tasks);
$db->update('%s_config', array('value' => $time), "class='task' and name='update{$i_task}'");
}
}
//开始执行每日计划任务
if (kc_config('task.day') != $today) {
$tasks = $file->getDir('task/day/', 'php');
if (!empty($tasks)) {
foreach ($tasks as $k => $v) {
require ROOT . $k;
}
}
unset($tasks);
$db->update('%s_config', array('value' => $today), "class='task' and name='day'");
}
//刷新即可执行
$tasks = $file->getDir('task/0/', 'php');
if (!empty($tasks)) {
foreach ($tasks as $k => $v) {
require ROOT . $k;
}
}
}
示例6: addNewFromFiles
/**
* Adding new files from Request in begin of uploading
*
* @param file $files
*/
public function addNewFromFiles($files)
{
$file = $files->get('file');
$fileFullName = $file->getClientOriginalName();
$this->status = self::STATUS_NEW;
$this->fullname = $fileFullName;
$fileParts = explode(".", $fileFullName);
$this->ext = end($fileParts);
$this->name = str_replace('.' . $this->ext, '', $fileFullName);
$this->created = time();
$this->mime = $file->getMimeType();
$this->size = $file->getSize();
$this->save();
return $this;
}
示例7: getSampleCode
public static function getSampleCode($assignment_id, $code_id = null)
{
$path = dirname(dirname(dirname(__FILE__))) . "/files/sample_code/" . $assignment_id . "/";
if (is_null($code_id)) {
$files = file::dirContent();
}
}
示例8: getUnInstalled
public function getUnInstalled()
{
$installed = (array) $this->getInstalled();
$folders = dir::folders(ZPATH_MODULES, '.', false);
$folders = array_diff($folders, array_keys($installed));
$modules = array();
foreach ($folders as $folder) {
$modulePath = ZPATH_MODULES . DS . $folder;
$moduleUrl = url::modules() . '/' . $folder;
$moduleFile = $modulePath . DS . 'module.php';
if (file::exists($moduleFile)) {
$m = (include $moduleFile);
$m['path'] = '$modules/' . $folder;
$m['url'] = '$modules/' . $folder;
if (!isset($m['icon'])) {
if (!file::exists($modulePath . '/icon.png')) {
$m['icon'] = url::theme() . '/image/skin/none.png';
} else {
$m['icon'] = $moduleUrl . '/icon.png';
}
}
$modules[$m['id']] = $m;
}
}
return $modules;
}
示例9: eqphp_autoload
function eqphp_autoload($class)
{
if (isset($_SERVER['REQUEST_URI'])) {
$root = current(explode('/', trim($_SERVER['REQUEST_URI'], '/')));
}
//optimize: $config save memcache or redis
$group = config('group.list');
$path = isset($root) && is_array($group) && in_array($root, $group) ? $root . '/' : '';
$module = array('a' => $path . 'action', 'm' => $path . 'model', 'p' => $path . 'plugin', 's' => 'server');
$prefix = substr($class, 0, strpos($class, '_'));
$dir_name = in_array($prefix, array('a', 'm', 's', 'p')) ? $module[$prefix] : 'class';
$execute_file = $dir_name . '/' . $class . '.php';
if (file_exists($execute_file)) {
return include PATH_ROOT . $execute_file;
}
//通用加载
if (config('state.common_load') && in_array($prefix, array('a', 'm'), true)) {
$common_option = array('a' => 'action/', 'm' => 'model/');
$execute_file = PATH_ROOT . $common_option[$prefix] . $class . '.php';
if (file_exists($execute_file)) {
return include $execute_file;
}
}
//贪婪加载
if (config('state.greedy_load')) {
$execute_file = file::search(PATH_ROOT . $dir_name, $class, $file_list, true);
if ($execute_file) {
return include $execute_file;
}
}
if ($prefix === 'a') {
logger::notice('class [' . $class . '] not found');
http::send(404);
}
}
示例10: CheckTemplate
/**
*
* @static
* @param string $filename
* @return bool
*/
public static function CheckTemplate($filename = "")
{
try {
if (empty($filename)) {
$objTemplate = new file(THEME_PREFIX . Settings::$page_templates_path . self::$template);
return $objTemplate->Exists();
} else {
$objTemplate = new file(THEME_PREFIX . Settings::$page_templates_path . $filename);
return $objTemplate->Exists();
}
} catch (Exception $e) {
Debug::Log($e, ERROR);
return false;
}
return true;
}
示例11: execTinyMce
protected function execTinyMce($prm=null) {
$search = 'js/tiny_mce/';
$request = request::get('request');
$pos = strpos($request, $search);
if ($pos === false)
exit;
$tmp = substr($request, $pos+strlen($search));
$file = file::nyroExists(array(
'name'=>'lib'.DS.'tinyMce'.DS.$tmp,
'realName'=>true,
'type'=>'other'
));
if (strpos($file, '.php') !== false) {
array_walk($_GET, create_function('&$v', '$v = urldecode($v);'));
$path = str_replace($tmp, '', $file);
ini_set('include_path', $path);
define('TINYMCEPATH', substr($path, 0, -1));
define('TINYMCECACHEPATH', substr(TMPROOT, 0, -1));
if (ob_get_length())
ob_clean();
include($file);
exit;
} else
response::getInstance()->showFile($file);
}
示例12: get_file_list
function get_file_list($dir, $attimg)
{
$imgname['size'] = 0;
foreach ($dir as $filedirs) {
$filedir = HDWIKI_ROOT . '/' . $filedirs;
file::forcemkdir($filedir);
$handle = opendir($filedir);
$i = 0;
while ($filename = readdir($handle)) {
if (!is_dir($filedir . '/' . $filename) && '.' != $filename && '..' != $filename && '.svn' != $filename && 'index.htm' != $filename) {
$fstr = explode(".", $filename);
$flast = substr(strrchr($fstr[0], '_'), 1);
if (!in_array($filedirs . '/' . $filename, $attimg)) {
//if !in_array($filedirs.'/'.$filename,$attimg) && $flast!='140' && $flast!="s"
$i++;
$imgname[] = $filedirs . '/' . $filename;
$imgname['size'] += filesize($filedir . '/' . $filename);
}
}
}
$imgname['num'] = $i;
closedir($handle);
}
return $imgname;
}
示例13: get_upload_data
/**
* get full information for an upload
*
* @param string $file
* @param array $file_data
* @return array
* @author Andy Bennett
*/
function get_upload_data($file, $file_data)
{
$filename = self::save($file);
if (APPENV == 'frontend') {
$upl_dir = str_replace('frontend', 'backend', Kohana::config('upload.directory'));
if (!copy($filename, $upl_dir . basename($filename))) {
Kohana::log('error', "COPY FAILED: copy({$filename}, {$upl_dir}.basename({$filename}))");
}
}
$pp = pathinfo($filename);
$ext = $pp['extension'];
$file_type = self::check_filetype($file_data['type'], $filename);
$d = Kohana::config('upload.directory');
$upload_data['file_name'] = $pp['basename'];
$upload_data['file_type'] = $file_type;
$upload_data['file_path'] = $d;
$upload_data['full_path'] = $filename;
$upload_data['raw_name'] = $pp['filename'];
$upload_data['orig_name'] = $file_data['name'];
$upload_data['file_ext'] = '.' . strtolower($ext);
$upload_data['file_size'] = $file_data['size'];
$upload_data['is_image'] = file::is_image($file_type);
$upload_data['date_added'] = date('Y-m-d H:i:s');
if ($upload_data['is_image']) {
$properties = file::get_image_properties($filename);
if (!empty($properties)) {
$upload_data = array_merge($upload_data, $properties);
}
}
return $upload_data;
}
示例14: install
public function install($path)
{
$module = @(include path::decode($path . DS . 'module.php'));
if (is_array($module)) {
$module['path'] = $path;
$module['url'] = $path;
if (!isset($module['icon'])) {
if (file::exists($path . '/icon.png')) {
$module['icon'] = $module['url'] . '/icon.png';
}
}
$module['type'] = empty($module['type']) ? 'plugin' : $module['type'];
$module['status'] = 0;
$module['order'] = $this->max('order') + 1;
$module['installtime'] = TIME;
$module['updatetime'] = TIME;
$insert = $this->insert($module);
}
if ($insert) {
$driver = $this->db()->config('driver');
$sqls = file::read($path . DS . 'install' . DS . $driver . '.sql');
if ($sqls) {
$this->db()->run($sqls);
}
}
return true;
}
示例15: save
/**
* start upload
+-----------------------------------------
* @access public
* @param string $path
* @return void
*/
public function save($path = '/', $web_path = '')
{
// check dir
if (!is_dir($path)) {
$this->error = 2404;
return false;
} else {
if (!file::_is_writable($path)) {
$this->error = 2655;
return false;
}
}
$files_rs = array();
$this->save_path = $path;
$this->web_path = $web_path;
$this->file_upload_count = 0;
foreach ($_FILES as $name => $file) {
$files_rs[$name] = array();
if (is_array($file['name'])) {
$this->multiple($file['name'], $file['type'], $file['tmp_name'], $file['error'], $file['size'], $files_rs[$name]);
} else {
$files_rs[$name] = $this->_save($file);
}
}
return $files_rs;
}