本文整理汇总了PHP中file::upload方法的典型用法代码示例。如果您正苦于以下问题:PHP file::upload方法的具体用法?PHP file::upload怎么用?PHP file::upload使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类file
的用法示例。
在下文中一共展示了file::upload方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: Field
<?php
require_once '_toolkit/main.php';
//var_export($_FILES);
if ($_FILES) {
$file = file::upload('image', 'data/image/' . $_FILES['image']['name']);
$ext = $file->getExtension();
$file->rename('background' . $ext);
$file->move('backgrounds/1/');
echo $file->getBaseName() . html::br();
echo $file->getFolder() . html::br();
echo $file->getPath() . html::br();
$img = $file->getImage();
if ($img !== false) {
$img->resize(100, 75);
}
//echo $img->htmlTag();
echo html::img($file);
//$file->delete();
} else {
echo form::init(NULL, NULL, 'multipart/form-data');
echo new Field('image', 'file');
echo form::submit();
echo '</form>';
}
示例3: import_from_file_id
public static function import_from_file_id($file_id, $model_class, $options = array())
{
$result = array('success' => false, 'error' => array());
do {
$file_name = time() . '_' . rand(10000, 99999) . '_' . rand(10000, 99999) . '_' . trim($_FILES[$file_id]['name']);
$directory = application::get(array('directory', 'temp', 'dir'));
$file_result = file::upload($file_id, $file_name, $directory, array_keys(self::$formats));
if (!$file_result['success']) {
$result['error'] = array_merge($result['error'], $file_result['error']);
break;
}
$import_result = self::import($file_result['file_name_full'], $model_class, $options);
if ($import_result['error']) {
array_merge3($result['error'], $import_result['error']);
break;
}
$result['success'] = true;
} while (0);
return $result;
}
示例4: function
<?php
_::define_controller('download', function () {
_::declare_component('file');
// force download uploads/file.php
$file = new file('uploads/', 'file.php');
$file->download();
});
_::define_controller('upload', function () {
_::declare_component('file');
// for upload:
$file = new file();
$location = $file->upload('FIELD', 'uploads/', true, true, array('jpg', 'jpeg', 'png', 'gif'));
});
示例5: ckupload
public function ckupload()
{
$dir = 'data/pics/';
$upload = file::upload('upload', $dir);
//上传图片
if (isset($upload['error'])) {
echo 'upload error ' . $upload['error'];
} else {
if ($upload['success']) {
$url = IMG_URL . $dir . $upload['success'][0];
$fn = $this->req('CKEditorFuncNum');
echo "<script>window.parent.CKEDITOR.tools.callFunction('{$fn}', '{$url}');</script>";
} else {
echo -1;
}
}
}