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


PHP File::upload方法代码示例

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


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

示例1: index

 public function index()
 {
     $db = MySQL::getInstance();
     if (isset($this->data[0]) && $this->data[0] == 'save') {
         foreach ($this->post as $name => $value) {
             $db->query('UPDATE `config` SET `FieldValue` = ' . $db->escape($value) . ' WHERE `FieldName` = ' . $db->escape($name));
         }
         foreach ($_FILES as $field => $file) {
             if ($fileName = File::upload('var/upload/', $field, true, true)) {
                 $db->query("SELECT `FieldValue` FROM `config` WHERE `FieldName` = " . $db->escape($field));
                 if ($oldFile = $db->fetchField()) {
                     File::delete($oldFile, 'var/upload/');
                 }
                 $db->query('UPDATE `config` SET `FieldValue` = ' . $db->escape($fileName) . ' WHERE `FieldName` = ' . $db->escape($field));
                 if ($field == "Banner") {
                     File::imageCrop($fileName, 'var/upload/', 699, 122);
                 }
             }
         }
         redirect(BASE_PATH . 'admin/cp');
     }
     $this->show->configData = array();
     $db->query('SELECT FieldName, FieldValue, FieldDescription, FieldType FROM `config` ORDER BY SortOrder');
     while (list($key, $value, $description, $type) = $db->fetchRow()) {
         $this->show->configData[] = array('Key' => $key, 'Value' => $value, 'Description' => $description, 'Type' => $type);
     }
 }
开发者ID:kizz66,项目名称:meat,代码行数:27,代码来源:Cp.php

示例2: execute

 public function execute()
 {
     $this->params = $this->extractRequestParams();
     // Extract the file and archiveName from the request parameters
     $this->validateParameters();
     // Check whether we're allowed to revert this file
     $this->checkPermissions($this->getUser());
     $sourceUrl = $this->file->getArchiveVirtualUrl($this->archiveName);
     $status = $this->file->upload($sourceUrl, $this->params['comment'], $this->params['comment']);
     if ($status->isGood()) {
         $result = array('result' => 'Success');
     } else {
         $result = array('result' => 'Failure', 'errors' => $this->getResult()->convertStatusToArray($status));
     }
     $this->getResult()->addValue(null, $this->getModuleName(), $result);
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:16,代码来源:ApiFileRevert.php

示例3: updateMe

 public function updateMe($inputs)
 {
     $this->name = $inputs['name'];
     $this->lastName = $inputs['lastName'];
     $this->city_id = $inputs['city_id'];
     $this->country_id = $inputs['country_id'];
     $this->province_id = $inputs['province_id'];
     $this->village = $inputs['village'];
     $this->hive_count = $inputs['hive_count'];
     $this->cooperative_member = isset($inputs['cooperative_member']) ? $inputs['cooperative_member'] : 0;
     $this->union_beekeeper_member = isset($inputs['union_beekeeper_member']) ? $inputs['union_beekeeper_member'] : 0;
     $this->phone = $inputs['phone'];
     $this->email = $inputs['email'];
     //        $this->month_record           = $inputs[''];
     $this->year_record = $inputs['year_record'];
     $this->beekeeping_book_code = $inputs['beekeeping_book_code'];
     $this->post_code = $inputs['post_code'];
     $this->beekeeping_as_main_job = isset($inputs['beekeeping_as_main_job']) ? $inputs['beekeeping_as_main_job'] : 0;
     $this->amount_of_honey_extraction_per_year = $inputs[''];
     $this->education_id = $inputs['education_id'];
     //        $this->picture                = $inputs[''];
     $this->description = $inputs['description'];
     $this->cellphone = $inputs['cellphone'];
     $this->union_name = $inputs['union_name'];
     $this->job_id = $inputs['job_id'];
     $this->location = $inputs['location'];
     $this->practice = serialize($inputs['practice']);
     $this->picture = isset($_FILES['picture']) ? \File::upload($_FILES['picture'])->url : null;
     $this->save();
 }
开发者ID:hasangilak,项目名称:wp-semi-laravel,代码行数:30,代码来源:UserMeta.php

示例4: app

 /**
  * The resume application handler.
  * 
  * @access public
  * @return string The JSON response.
  */
 public function app()
 {
     $response = array('result' => 0, 'posted' => 0);
     if (Request::get('Name') && Request::get('Email') && Request::get('Phone') && !Request::get('Message')) {
         $response['posted'] = 1;
         $Resume = new Resume();
         $Resume->setPost($_POST);
         $fields = Error::test($Resume);
         if (count($fields)) {
             $response['msg'] = 'Неверно заполнены поля: ' . implode(', ', $fields);
         } else {
             $Resume->Id = rand(1, 1000000);
             if (!empty($_FILES['file']['tmp_name'])) {
                 File::upload($Resume, $_FILES['file']);
             }
             $Email = new Email_Resume($Resume);
             if ($Email->send()) {
                 $response['result'] = 1;
             } else {
                 $response['msg'] = 'Ошибка отправки e-mail';
             }
             File::detach($Resume);
         }
     }
     return $this->outputJSON($response);
 }
开发者ID:vosaan,项目名称:ankor.local,代码行数:32,代码来源:announces.php

示例5: upload

 /**
  * The function uploads Benefit examples.
  * 
  * @access public
  * @param int $id The Benefit id.
  * @return string The JSON response.
  */
 public function upload($id = null)
 {
     $response = array('result' => 0);
     if (isset($_POST['upload'])) {
         $Benefit = new Benefit();
         $Benefit = $Benefit->findItem(array('Id = ' . $id));
         if ($Benefit->Id) {
             if (empty($_FILES['example']['tmp_name'])) {
                 $response['msg'] = 'Выберите файл';
             } else {
                 $Example = new Benefit_Example();
                 $Example->BenefitId = $Benefit->Id;
                 if ($Example->save()) {
                     if (File::upload($Example, $_FILES['example'])) {
                         $Example->save();
                         $response['result'] = 1;
                         $response['html'] = $this->getView()->htmlExamples($Benefit);
                     } else {
                         $response['msg'] = 'Не удалось загрузить файл';
                     }
                 } else {
                     $response['msg'] = 'Ошибка записи данных';
                 }
             }
         } else {
             $response['msg'] = 'Продукция не найдена';
         }
     }
     return $this->outputJSON($response);
 }
开发者ID:vosaan,项目名称:ankor.local,代码行数:37,代码来源:images.php

示例6: upload

 function upload()
 {
     $file = new File();
     //we check access in the upload function
     if ($file->upload()) {
         Response($file);
     } else {
         Response()->error($file->errors());
     }
 }
开发者ID:neevan1e,项目名称:Done,代码行数:10,代码来源:files.controller.php

示例7: user_update_0

function user_update_0()
{
    //this should be replaced with a user save but that requires a full bootstrap :(
    $sql = "REPLACE INTO `user` (`uid`, `email`, `username`, `password`, `created`, `updated`, `deleted`, `status`, `firstname`, `lastname`, `profile`, `location`, `age`, `picture`, `gender`)\nVALUES\n    (2, 'nodefortytwo@gmail.com', 'nodefortytwo', '5133b5ed586f3107c016ab3440d1f251', 1346599169, 1346599169, 0, 1, 'Rick', 'Burgess', '', '4c03d3af187ec9287322b67b', 25, '', 'Male');\n    ";
    db()->query($sql);
    file_init();
    $file = array('name' => 'default-profile.gif', 'tmp_name' => cwd() . '/' . PATH_TO_MODULES . '/user/img/default-profile.gif', 'type' => 'image/gif');
    $f = new File();
    $f->upload($file);
    var_set('DEFAULT_PROFILE_PIC', $f->id);
}
开发者ID:nodefortytwo,项目名称:areyouhappy,代码行数:11,代码来源:user.install.php

示例8: process

 public function process()
 {
     if ($this->field_data['tmp_name'] !== '') {
         $destination = BASE_PATH . '/' . $this->settings['destination'];
         $filename = File::cleanFilename($this->field_data['name']);
         if (File::upload($this->field_data['tmp_name'], $destination, $filename)) {
             return Path::tidy('/' . $this->settings['destination'] . '/' . $filename);
         } else {
             Log::fatal($this->field_data['tmp_name'] . ' could up not be uploaded to ' . $destination, 'core');
             return '';
         }
     }
 }
开发者ID:nob,项目名称:joi,代码行数:13,代码来源:ft.file.php

示例9: testSaveNew

 /**
  * Uploading a file should not fail.
  */
 public function testSaveNew()
 {
     $at = getenv("BB_ACCESS_TOKEN");
     $tmpDirName = sys_get_temp_dir();
     $tmpFileName = md5(rand()) . '.gif';
     $tmpFilePath = $tmpDirName . DIRECTORY_SEPARATOR . $tmpFileName;
     $tmpFile = fopen($tmpFilePath, 'w');
     fwrite($tmpFile, 'Test file created by ' . __METHOD__);
     fclose($tmpFile);
     $object = File::upload($at, $tmpFilePath);
     unlink($tmpFilePath);
     $this->assertInstanceOf('\\ClausConrad\\BillysBilling\\File', $object, 'Uploading a file returns a File instance.');
     return $object;
 }
开发者ID:cconrad,项目名称:billysbilling-v2-php-sdk,代码行数:17,代码来源:FileTest.php

示例10: insertProcess

function insertProcess()
{
    $send = Request::get('send');
    $valid = Validator::make(array('send.title' => 'required|min:1|slashes', 'send.parentid' => 'slashes'));
    if (!$valid) {
        throw new Exception("Error Processing Request: " . Validator::getMessage());
    }
    if (Request::hasFile('image')) {
        if (Request::isImage('image')) {
            $send['image'] = File::upload('image');
        }
    }
    if (!($id = Categories::insert($send))) {
        throw new Exception("Error. " . Database::$error);
    }
}
开发者ID:neworldwebsites,项目名称:noblessecms,代码行数:16,代码来源:categories.php

示例11: upload

 /**
  * Upload the attachment
  *
  * @param  array  $input
  * @return bool
  */
 public static function upload($input)
 {
     $path = \Config::get('application.upload_path');
     if (!file_exists($path = $path . $input['project_id'])) {
         mkdir($path);
     }
     if (!file_exists($path = $path . '/' . $input['upload_token'])) {
         mkdir($path);
     }
     $file = \Input::file('Filedata');
     \File::upload('Filedata', $file_path = $path . '/' . $file['name']);
     $fill = array('uploaded_by' => \Auth::user()->id, 'filename' => $file['name'], 'fileextension' => \File::extension($file_path), 'filesize' => $file['size'], 'upload_token' => $input['upload_token']);
     $attachment = new static();
     $attachment->fill($fill);
     $attachment->save();
     return true;
 }
开发者ID:eliasyanni,项目名称:bugs,代码行数:23,代码来源:attachment.php

示例12: control

 public function control()
 {
     $this->redirectToSternIndiaEndPoint();
     $config = Config::getInstance();
     if (isset($_POST['upload']) && $_POST['upload'] == 'Upload') {
         $target_dir = new FileSystem('upload/');
         $file = new File('foo', $target_dir);
         $name = date('D_d_m_Y_H_m_s_');
         $name = $name . $file->getName();
         $file->setName($name);
         $config = Config::getInstance();
         $file->addValidations(array(new Mimetype($config->getMimeTypes()), new Size('5M')));
         $data = array('name' => $file->getNameWithExtension(), 'extension' => $file->getExtension(), 'mime' => $file->getMimetype(), 'size' => $file->getSize(), 'md5' => $file->getMd5());
         try {
             // /Profiler::debugPoint(true,__METHOD__, __FILE__, __LINE__,$data);
             $file->upload();
             //Profiler::debugPoint(true,__METHOD__, __FILE__, __LINE__,$data);
         } catch (Exception $e) {
             $errors = $file->getErrors();
         }
         $csvReader = new CSVReader();
         $destinationFile = $target_dir->directory . $file->getNameWithExtension();
         $data = $csvReader->parse_file($destinationFile);
         //$country= DAOFactory::getDAO('LocationDAO');
         foreach ($data as $loc_arr) {
             Utils::processLocation($loc_arr);
         }
         //Profiler::debugPoint(true,__METHOD__, __FILE__, __LINE__);
         $target_dir = "uploads/";
         $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
         $uploadOk = 1;
         $imageFileType = pathinfo($target_file, PATHINFO_EXTENSION);
         // Check if image file is a actual image or fake image
         if (isset($_POST["submit"])) {
             $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
             if ($check !== false) {
                 echo "File is an image - " . $check["mime"] . ".";
                 $uploadOk = 1;
             } else {
                 echo "File is not an image.";
                 $uploadOk = 0;
             }
         }
     }
     return $this->generateView();
 }
开发者ID:prabhatse,项目名称:olx_hack,代码行数:46,代码来源:class.FileUploadController.php

示例13: update

 public function update($data, $brandID)
 {
     if ((int) $brandID == 0) {
         return $this->insert($data);
     }
     if (empty($data['Title'])) {
         throw new Exception(lang('data_empty', __CLASS__));
     }
     $db = MySQL::getInstance();
     $queryStr = "";
     if ($imageName = File::upload('var/brand/')) {
         $this->deleteFile($brandID);
         File::imageCrop($imageName, 'var/brand/', 120, 120);
         $queryStr .= ', `Image` = ' . $db->escape($imageName);
     }
     $db->query("UPDATE `catalog_brand` SET\n\t\t\t\t`Title` = " . $db->escape($data['Title'], 255) . ",\n\t\t\t\t`Description` = " . $db->escape($data['Description'], 255) . ",\n\t\t\t\t`Content` = " . $db->escape($data['Content']) . "\n\t\t\t\t" . $queryStr . "\n\t\t\tWHERE `BrandID` = " . $db->escape((int) $brandID));
     return true;
 }
开发者ID:kizz66,项目名称:meat,代码行数:18,代码来源:Brand.php

示例14: execute

 function execute()
 {
     $files = Request::files('photo');
     if (!$files || sizeof($files) == 0) {
         return;
     }
     $user = ConnectionHelper::userLogin();
     $uploadDir = ConnectionHelper::getPhotoDir($user['id']);
     $model = new connectionUserPhotoModel();
     File::mkdir($uploadDir);
     foreach ($files as $file) {
         $file_info = pathinfo($file['name']);
         if (!in_array(strtolower($file_info['extension']), array('png', 'jpeg', 'jpg', 'gif'))) {
             continue;
         }
         $file_name = uniqid() . strtotime('now') . md5(rand()) . '.' . $file_info['extension'];
         File::upload($file, $uploadDir, $file_name);
         $model->addPhoto($user['id'], $file_name);
     }
 }
开发者ID:Yogurt933,项目名称:Made-Easy,代码行数:20,代码来源:connectionProfilePhotoUpload.action.php

示例15: execute

 function execute()
 {
     $status = 'success';
     $model = connectionSliderModel::create();
     $locale = new Locales('connection');
     $list = $locale->getList();
     $data = Request::post('slide');
     if (!isset($data['link']) || empty($data['link'])) {
         $status = 'error';
     } else {
         if (isset($data['id'])) {
             $slide = $model->where(array('id' => (int) $data['id']))->fetchOne();
         }
         $dir = UPLOAD_DIR . DS . 'slider' . DS;
         File::mkdir($dir);
         foreach ($list as $lang) {
             $file = Request::files('slide_' . $lang['iso']);
             if (!$file || empty($file[0]['name'])) {
                 if (isset($data['id'])) {
                     $data[$lang['iso']]['image'] = isset($slide[$lang['iso']]['image']) ? $slide[$lang['iso']]['image'] : '';
                 }
                 continue;
             }
             $file = $file[0];
             $info = pathinfo($file['name']);
             $name = strtotime('now') . md5($file['name']) . uniqid() . '.' . $info['extension'];
             File::upload($file, $dir, $name);
             $data[$lang['iso']]['image'] = $name;
         }
         if (isset($data['id'])) {
             $id = $data['id'];
             unset($data['id']);
             $model->where(array('id' => (int) $id))->update($data);
         } else {
             $data['sort'] = 0;
             $model->insert($data);
         }
     }
     return array('status' => $status);
 }
开发者ID:Yogurt933,项目名称:Made-Easy,代码行数:40,代码来源:connectionSliderSave.action.php


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