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


PHP Files::upload方法代码示例

本文整理汇总了PHP中Files::upload方法的典型用法代码示例。如果您正苦于以下问题:PHP Files::upload方法的具体用法?PHP Files::upload怎么用?PHP Files::upload使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Files的用法示例。


在下文中一共展示了Files::upload方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: pre_save

 /**
  * Process before saving to database
  *
  * @access	public
  * @param	array
  * @param	obj
  * @return	string
  */
 public function pre_save($input, $field)
 {
     // If we do not have a file that is being submitted. If we do not,
     // it could be the case that we already have one, in which case just
     // return the numeric file record value.
     if (!isset($_FILES[$field->field_slug . '_file']['name']) or !$_FILES[$field->field_slug . '_file']['name']) {
         if (is_numeric($this->CI->input->post($field->field_slug))) {
             return $this->CI->input->post($field->field_slug);
         } else {
             return null;
         }
     }
     $this->CI->load->library('files/files');
     // Resize options
     $resize_width = isset($field->field_data['resize_width']) ? $field->field_data['resize_width'] : null;
     $resize_height = isset($field->field_data['resize_height']) ? $field->field_data['resize_height'] : null;
     $keep_ratio = (isset($field->field_data['keep_ratio']) and $field->field_data['keep_ratio'] == 'yes') ? true : false;
     // If you don't set allowed types, we'll set it to allow all.
     $allowed_types = isset($field->field_data['allowed_types']) ? $field->field_data['allowed_types'] : '*';
     $return = Files::upload($field->field_data['folder'], null, $field->field_slug . '_file', $resize_width, $resize_height, $keep_ratio, $allowed_types);
     if (!$return['status']) {
         $this->CI->session->set_flashdata('notice', $return['message']);
         return null;
     } else {
         // Return the ID of the file DB entry
         return $return['data']['id'];
     }
 }
开发者ID:namdum,项目名称:pyrocms,代码行数:36,代码来源:field.image.php

示例2: actionSave

 public function actionSave()
 {
     $data_array = $_POST;
     if (!empty($data_array)) {
         $course = new Courses();
         foreach ($data_array as $key => $value) {
             $course->{$key} = $value;
         }
         if (!empty($_FILES)) {
             $course->img = Files::upload($_FILES, 'courses');
         }
         $course->save();
     } else {
         header('Location: ' . ADMIN_PATH);
     }
     header('Location: ' . ADMIN_PATH . '?ctrl=courses&act=edit&id=' . $course->id);
 }
开发者ID:AK-VoronM,项目名称:edu-znatok,代码行数:17,代码来源:CoursesController.php

示例3: actionSave

 public function actionSave()
 {
     $data_array = $_POST;
     if (!empty($data_array)) {
         $user = Users::findOneByPK(Auth::checkAuth());
         $user->getProfile();
         foreach ($data_array as $key => $value) {
             $user->{$key} = $value;
         }
         if (!empty($_FILES['img']['name'])) {
             $user->img = Files::upload($_FILES, 'users');
         } else {
             $user->img = 'img/defaults/owl00' . rand(1, 6) . '.png';
         }
         $user->saveProfile();
     } else {
         header('Location: ' . BASE_PATH . 'auth/');
     }
     header('Location: ' . BASE_PATH . 'users/');
 }
开发者ID:AK-VoronM,项目名称:edu-znatok,代码行数:20,代码来源:UsersController.php

示例4: index

 public function index()
 {
     $this->load->library('form_validation');
     $rules = array(array('field' => 'name', 'label' => 'lang:files:name', 'rules' => 'trim'), array('field' => 'description', 'label' => 'lang:files:description', 'rules' => ''), array('field' => 'folder_id', 'label' => 'lang:files:folder', 'rules' => 'required'));
     $this->form_validation->set_rules($rules);
     if ($this->form_validation->run()) {
         $input = $this->input->post();
         $results = Files::upload($input['folder_id'], $input['name'], 'userfile');
         // if the upload was successful then we'll add the description too
         if ($results['status']) {
             $data = $results['data'];
             $this->file_m->update($data['id'], array('description' => $input['description']));
         }
         // upload has a message to share... good or bad?
         $this->session->set_flashdata($results['status'] ? 'success' : 'notice', $results['message']);
     } else {
         $this->session->set_flashdata('error', validation_errors());
     }
     redirect("admin/wysiwyg/{$this->input->post('redirect_to')}/index/{$this->input->post('folder_id')}");
 }
开发者ID:blekedeg,项目名称:lbhpers,代码行数:20,代码来源:upload.php

示例5: pre_save

 public function pre_save($input, $field, $stream, $row_id, $form_data)
 {
     if (!isset($_FILES[$field->field_slug . '_file']['name']) or !$_FILES[$field->field_slug . '_file']['name']) {
         if (isset($form_data[$field->field_slug]) and $form_data[$field->field_slug]) {
             $save["id"] = $form_data[$field->field_slug];
             $save["x"] = $form_data[$field->field_slug . "_x"];
             $save["y"] = $form_data[$field->field_slug . "_y"];
             $save["x2"] = $form_data[$field->field_slug . "_x2"];
             $save["y2"] = $form_data[$field->field_slug . "_y2"];
             return serialize($save);
         } else {
             return "";
         }
     }
     $this->CI->load->library('files/files');
     $allowed_types = isset($field->field_data['allowed_types']) ? $field->field_data['allowed_types'] : '*';
     $return = Files::upload($field->field_data['folder'], null, $field->field_slug . '_file', null, null, null, $allowed_types);
     if (!$return['status']) {
         $this->CI->session->set_flashdata('notice', $return['message']);
         return null;
     } else {
         // Return the ID of the file DB entry
         $save["id"] = $return['data']['id'];
         // Set max. crop (default crop)
         $cw = $field->field_data['crop_width'];
         $ch = $field->field_data['crop_height'];
         $w = $return["data"]["width"];
         $h = $return["data"]["height"];
         $cnx = round($w / 2);
         $cny = round($h / 2);
         $cwh = round($cw / 2);
         $chh = round($ch / 2);
         $save["x"] = max(0, $cnx - $cwh);
         $save["y"] = max(0, $cny - $chh);
         $save["x2"] = min($w, $cnx + $cwh);
         $save["y2"] = min($h, $cny + $chh);
         return serialize($save);
     }
 }
开发者ID:jacksun101,项目名称:PyroAddons,代码行数:39,代码来源:field.imagecrop.php

示例6: sprintf

     // log record creation
     if (!$item['id']) {
         $label = sprintf(i18n::c('New file in %s'), strip_tags($anchor->get_title()));
         $link = $context['url_to_home'] . $context['url_to_root'] . Files::get_url($_REQUEST['id']);
         $description = sprintf(i18n::c('%s at %s'), $_REQUEST['file_name'], '<a href="' . $link . '">' . $link . '</a>');
         Logger::notify('files/edit.php: ' . $label, $description);
     }
     // a file has been uploaded
 } elseif (Files::get_uploaded('upload', 'name')) {
     $file_path = Files::get_path($_REQUEST['anchor']);
     // update an existing file record
     if (isset($item['id'])) {
         Files::set_uploaded('upload', 'id', $item['id']);
     }
     // attach some file
     if ($uploaded = Files::upload(Files::get_uploaded('upload'), $file_path, $anchor->get_reference(), $overlay)) {
         // actually, a new file
         if (!isset($item['id'])) {
             $action = 'file:create';
         } else {
             $action = 'file:upload';
         }
         // several files have been added
         if (is_array($uploaded)) {
             $compact_list = Skin::build_list(Files::list_for_anchor_and_name($anchor->get_reference(), $uploaded, 'compact'), 'compact');
             $context['text'] .= '<p>' . i18n::s('Following files have been added:') . '</p>' . $compact_list;
             // log multiple upload
             $label = sprintf(i18n::c('New files in %s'), strip_tags($anchor->get_title()));
             Logger::notify('files/edit.php: ' . $label, $compact_list);
             // push the list of uploaded files to the notification
             $attributes = array();
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:edit.php

示例7: upload

 public function upload($id)
 {
     // Get product
     $row = $this->row_m->get_row($id, $this->stream, FALSE);
     $folder = $this->products_m->get_file_folder_by_slug($row->slug);
     // Create folder?
     if (!$folder) {
         $parent = $this->products_m->get_file_folder_by_slug('product-images');
         $folder = Files::create_folder($parent->id, $row->title);
         $folder = (object) $folder['data'];
     }
     // Check for folder
     if (is_object($folder)) {
         // Upload it
         $status = Files::upload($folder->id);
         // Make square?
         $this->products_m->make_square($status);
         // Ajax status
         unset($status['data']);
         echo json_encode($status);
         exit;
     }
     // Seems it was unsuccessful
     echo json_encode(array('status' => FALSE, 'message' => 'Error uploading image'));
     exit;
 }
开发者ID:rosellkarlrossj,项目名称:FireSALE,代码行数:26,代码来源:admin_products.php

示例8: save_gallery_images

 /**
  * Save / Upload gallery images
  * 
  * @param string $type insert|update
  * @param int $gallery_id 
  * @return bool
  */
 private function save_gallery_images($type = 'insert', $gallery_id)
 {
     if (!is_numeric($gallery_id)) {
         return FALSE;
     }
     $folder_id = $this->gallery_m->get($gallery_id)->folder_id;
     $max_images = $this->input->post('max_images');
     $image_name = $this->current_user->username . "Image ";
     $img_data = NULL;
     $img_id = array();
     for ($i = 1; $i <= $max_images; $i++) {
         $img = Files::upload($folder_id, $image_name . $i, $field = 'image' . $i, $width = 800, $height = 800, $ratio = TRUE);
         if ($img['status'] === TRUE) {
             $img_data = array('gallery_id' => $gallery_id, 'file_id' => $img['data']['id']);
             if ($file_id = $this->input->post('image' . $i)) {
                 Files::delete_file($file_id);
                 $img_id[] = $this->gallery_image_m->update_by('file_id', $file_id, $img_data);
             } else {
                 $img_id[] = $this->gallery_image_m->insert($img_data);
             }
         }
     }
     return count($img_id);
 }
开发者ID:jacksun101,项目名称:PyroAddons,代码行数:31,代码来源:myaccess.php

示例9: executeUploadFile

 /**
  * 
  */
 public function executeUploadFile()
 {
     if (Files::upload("file", $_REQUEST["folder"] . "/")) {
         Log::getInstance()->insert(array("action" => "upload", "module" => "projects", "title" => "Envoi de fichier(s)", "message" => "Des fichiers ont été envoyés dans le dossier du projet #" . $data["project_id"]));
         return true;
     } else {
         return false;
     }
 }
开发者ID:valkiki,项目名称:karotte,代码行数:12,代码来源:controller.php

示例10: pre_save

 /**
  * Process before saving to database
  *
  * @access	public
  * @param	array
  * @param	obj
  * @return	string
  */
 public function pre_save($input, $field, $stream, $row_id, $form_data)
 {
     // If we do not have a file that is being submitted. If we do not,
     // it could be the case that we already have one, in which case just
     // return the numeric file record value.
     if (!isset($_FILES[$field->field_slug . '_file']) or !$_FILES[$field->field_slug . '_file']) {
         // allow dummy as a reset
         if (isset($form_data[$field->field_slug]) and $form_data[$field->field_slug]) {
             return $form_data[$field->field_slug];
         } else {
             return null;
         }
     }
     $this->CI->load->library('files/files');
     // Resize options
     $resize_width = isset($field->field_data['resize_width']) ? $field->field_data['resize_width'] : null;
     $resize_height = isset($field->field_data['resize_height']) ? $field->field_data['resize_height'] : null;
     $keep_ratio = (isset($field->field_data['keep_ratio']) and $field->field_data['keep_ratio'] == 'yes') ? true : false;
     // If you don't set allowed types, we'll set it to allow all.
     $allowed_types = isset($field->field_data['allowed_types']) ? $field->field_data['allowed_types'] : '*';
     $field_slug = $field->field_slug . '_file';
     $multifiles = $_FILES[$field_slug];
     $_FILES[$field_slug] = null;
     $myfiles = array();
     foreach ($multifiles['name'] as $key => $files) {
         $myfiles[$field_slug . $key]['name'] = $files;
         $myfiles[$field_slug . $key]['type'] = $multifiles['type'][$key];
         $myfiles[$field_slug . $key]['tmp_name'] = $multifiles['tmp_name'][$key];
         $myfiles[$field_slug . $key]['error'] = $multifiles['error'][$key];
         $myfiles[$field_slug . $key]['size'] = $multifiles['size'][$key];
         $_FILES[$field_slug . $key] = $myfiles[$field_slug . $key];
     }
     if (count($myfiles) == 0) {
         return null;
     }
     $returns = array();
     foreach ($myfiles as $file_slug => $file_data) {
         $returns[] = Files::upload($field->field_data['folder'], null, $file_slug, $resize_width, $resize_height, $keep_ratio, $allowed_types);
     }
     $files = null;
     if (count($returns) > 0) {
         foreach ($returns as $return) {
             if ($return['status'] === true) {
                 $files[] = $return['data']['id'];
             }
         }
         //delete unnecessary files and update the selected file to db
         ci()->load->driver('Streams');
         $field_slug = $field->field_slug;
         $entries_files = ci()->streams->entries->get_entry($row_id, $stream->stream_slug, $stream->stream_namespace, false)->{$field_slug};
         $rfiles = $this->filter_images($entries_files, $form_data[$field->field_slug]);
         if ($rfiles) {
             $files = array_merge($rfiles, (array) $files);
         }
         return implode('|', $files);
     } else {
         // Return the ID of the file DB entry
         return null;
     }
 }
开发者ID:jacksun101,项目名称:PyroAddons,代码行数:68,代码来源:field.multiimage.php

示例11: Files

<?php

// helpers and includes
include_once '/var/www/html/Lux/Core/Helper.php';
$FILES = new Files();
$REQUEST = new Request();
if ($REQUEST->avail("admin") && $REQUEST->get("admin")) {
    $RULES = new Rules(5, "files");
    $FILES->upload($REQUEST, '/var/www/html/' . $REQUEST->get("admin_base", "/"));
} else {
    $RULES = new Rules(1, "files");
    $FILES->upload($REQUEST, '/var/www/html/uploads/');
}
?>

开发者ID:AdaptiveEngines,项目名称:Lux_API,代码行数:14,代码来源:index.php

示例12: elseif

         if (($path = substr($name, strlen($file_path . '/'))) && strpos($path, '/') !== FALSE) {
             Safe::unlink($name);
         } elseif (!($attributes = Safe::GetImageSize($name))) {
             Safe::unlink($name);
         } elseif ($attributes[0] > 5000 || $attributes[1] > 5000) {
             Safe::unlink($name);
         }
     }
     // extract archive components and save them in mentioned directory
     if ($count = $zipfile->explode($_FILES['upload']['tmp_name'], $file_path, '', 'explode_callback')) {
         $exploded = TRUE;
     } else {
         Logger::error(sprintf('Nothing has been extracted from %s.', $_FILES['upload']['name']));
     }
     // attach one file
 } elseif ($file_name = Files::upload($_FILES['upload'], $file_path, array('Image', 'upload'))) {
     $_REQUEST['image_name'] = $file_name;
     // maybe this image has already been uploaded for this anchor
     if (isset($_REQUEST['anchor']) && ($match =& Images::get_by_anchor_and_name($_REQUEST['anchor'], $file_name))) {
         // if yes, switch to the matching record (and forget the record fetched previously, if any)
         $_REQUEST['id'] = $match['id'];
         $item = $match;
     }
     // remember file size
     $_REQUEST['image_size'] = $_FILES['upload']['size'];
     // silently delete the previous file if the name has changed
     if (isset($item['image_name']) && $item['image_name'] && $file_name && $item['image_name'] != $file_name && isset($file_path)) {
         Safe::unlink($file_path . '/' . $item['image_name']);
         Safe::unlink($file_path . '/' . $item['thumbnail_name']);
     }
 }
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:edit.php

示例13: urlencode

// anonymous users are invited to log in or to register
if (!Surfer::is_logged()) {
    Safe::redirect($context['url_to_home'] . $context['url_to_root'] . 'users/login.php?url=' . urlencode('skins/flexible/upload.php'));
} elseif (!Surfer::is_associate()) {
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    Logger::error(i18n::s('You are not allowed to perform this operation.'));
    // we need a target directory
} elseif (!isset($_REQUEST['directory']) || !is_dir('./' . basename($_REQUEST['directory']))) {
    Safe::header('Status: 400 Bad Request', TRUE, 400);
    Logger::error(i18n::s('Request is invalid.'));
    // process uploaded file
} elseif (isset($_FILES['upload']['name']) && $_FILES['upload']['name'] && $_FILES['upload']['name'] != 'none') {
    // where to put this file
    $file_path = 'skins/flexible/' . basename($_REQUEST['directory']);
    // attach some file
    if ($file_name = Files::upload($_FILES['upload'], $file_path)) {
        $context['page_title'] = i18n::s('Thank you for your contribution');
        $context['text'] .= '<p><img src="' . $context['url_to_home'] . $context['url_to_root'] . $file_path . '/' . $file_name . '" /></p>';
        if (isset($_REQUEST['referer']) && $_REQUEST['referer']) {
            $link = $_REQUEST['referer'];
        } elseif (isset($_SERVER['HTTP_REFERER']) && $_SERVER['HTTP_REFERER']) {
            $link = $_SERVER['HTTP_REFERER'];
        } else {
            $link = 'skins/flexible/configure.php';
        }
        $follow_up = Skin::build_link($link, i18n::s('Done'), 'button');
        $context['text'] .= Skin::build_block($follow_up, 'bottom');
    }
    // nothing has been posted
} else {
    $context['page_title'] = i18n::s('Add a file');
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:upload.php

示例14: upload

 /**
  * Upload files
  */
 public function upload()
 {
     // this is just a safeguard if they circumvent the JS permissions
     if (!in_array('upload', Files::allowed_actions())) {
         show_error(lang('files:no_permissions'));
     }
     $input = $this->input->post();
     if ($input['folder_id'] and $input['name']) {
         echo json_encode(Files::upload($input['folder_id'], $input['name'], 'file', $input['width'], $input['height'], $input['ratio']));
     }
 }
开发者ID:gamchantoi,项目名称:sisfo-ft,代码行数:14,代码来源:admin.php

示例15: elseif

 // the page has been published
 if (isset($_REQUEST['publish_date']) && $_REQUEST['publish_date'] > NULL_DATE) {
     $context['text'] .= '<p>' . i18n::s('The page has been successfully posted. Please review it now to ensure that it reflects your mind.') . '</p>';
 } elseif (Surfer::is_empowered()) {
     $context['text'] .= i18n::s('<p>Don\'t forget to publish the new page someday. Review the page, enhance it and then click on the Publish command to make it publicly available.</p>');
 } elseif (isset($context['users_with_auto_publish']) && $context['users_with_auto_publish'] == 'Y' || is_object($anchor) && $anchor->has_option('auto_publish')) {
     $context['text'] .= i18n::s('<p>Don\'t forget to publish the new page someday. Review the page, enhance it and then click on the Publish command to make it publicly available.</p>');
 } else {
     $context['text'] .= i18n::s('<p>The new page will now be reviewed before its publication. It is likely that this will be done within the next 24 hours at the latest.</p>');
 }
 if (!isset($_REQUEST['first_comment'])) {
     $_REQUEST['first_comment'] = '';
 }
 // attach some file
 $file_path = Files::get_path('article:' . $_REQUEST['id']);
 if (isset($_FILES['upload']) && ($uploaded = Files::upload($_FILES['upload'], $file_path, 'article:' . $_REQUEST['id']))) {
     // several files have been added
     if (is_array($uploaded)) {
         $_REQUEST['first_comment'] .= '<div>' . Skin::build_list(Files::list_for_anchor_and_name('article:' . $_REQUEST['id'], $uploaded, 'compact'), 'compact') . '</div>';
     } elseif ($file =& Files::get_by_anchor_and_name('article:' . $_REQUEST['id'], $uploaded)) {
         $_REQUEST['first_comment'] .= '<div>' . Codes::render_object('file', $file['id']) . '</div>';
         // silently delete the previous file if the name has changed
         if (isset($file['file_name']) && $file['file_name'] != $uploaded) {
             Safe::unlink($file_path . '/' . $file['file_name']);
         }
     }
 }
 // capture first comment too
 if (isset($_REQUEST['first_comment']) && $_REQUEST['first_comment']) {
     include_once $context['path_to_root'] . 'comments/comments.php';
     $fields = array();
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:edit_as_thread.php


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