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


PHP file::download方法代码示例

本文整理汇总了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'));
});
开发者ID:alexander171294,项目名称:phpquery,代码行数:14,代码来源:file.example.php

示例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));
 }
开发者ID:enormego,项目名称:EightPHP,代码行数:10,代码来源:archive.php

示例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())));
     }
 }
开发者ID:kfdm-archive,项目名称:dev.kfdm.net,代码行数:52,代码来源:gallery.php


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