本文整理汇总了PHP中file::download方法的典型用法代码示例。如果您正苦于以下问题:PHP file::download方法的具体用法?PHP file::download怎么用?PHP file::download使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类file
的用法示例。
在下文中一共展示了file::download方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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'));
});
示例2: download
/**
* Forces a download of a created archive.
*
* @param string name of the file that will be downloaded
* @return void
*/
public function download($filename)
{
file::download($filename, $this->driver->create($this->paths));
}
示例3: _image_link
protected function _image_link($gallery)
{
if (request::is_ajax()) {
$this->_use_json_errors();
}
if ($gallery->id == 0) {
return View::global_error('Invalid Gallery id');
}
if (isset($_POST['username']) && isset($_POST['password'])) {
Auth::instance()->login($_POST['username'], $_POST['password']);
}
if (!Auth::instance()->logged_in('login')) {
return View::global_error('Image upload requires login');
}
if ($gallery->user_id != 0 && $gallery->user_id != Auth::instance()->get_user()->id) {
return View::global_error('User not gallery owner');
}
if ($this->input->post('name') == '') {
View::global_error('Missing Image Name');
}
if ($this->input->post('file') == '') {
View::global_error('Missing File Name');
}
if (View::errors_set()) {
return;
}
$tmp = file::download($_POST['file']);
$image = ORM::factory('image');
$image->gallery_id = $gallery->id;
$image->name = $this->input->post('name');
$image->mime = file::mime($tmp);
$image->description = isset($_POST['description']) ? $_POST['description'] : $_POST['file'];
$image->size = filesize($tmp);
$image->uploaded_on = time();
$image->uploaded_by = Auth::instance()->get_user()->id;
if (!$image->validate()) {
return View::global_error('Error validating Image');
}
if (!$image->replace_uploaded_file($tmp)) {
return View::global_error('Error moving Image');
}
if (!$image->save()) {
return View::global_error('Error saving Image');
}
if (!$image->generate_thumb()) {
return View::global_error('Error generating thumb');
}
$_POST = array();
if (request::is_ajax()) {
die(json_encode(array('result' => 'OK', 'id' => $image->id, 'name' => $image->name, 'url' => $image->generate_url())));
}
}