當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。