本文整理汇总了PHP中Upload::get_files方法的典型用法代码示例。如果您正苦于以下问题:PHP Upload::get_files方法的具体用法?PHP Upload::get_files怎么用?PHP Upload::get_files使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Upload
的用法示例。
在下文中一共展示了Upload::get_files方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: moveUploadedFile
/**
* アップロードファイルを指定のフォルダに移動する
*
* @access public
* @param array $config アップロードの設定
* @return void
* @author kobayashi
* @author ida
*/
public static function moveUploadedFile($config)
{
$default = array('ext_whitelist' => array('jpg'), 'randomize' => true);
$config = array_merge($default, $config);
\Upload::process($config);
$is_upload = false;
$result = array();
if (\Upload::is_valid()) {
\Upload::save();
$files = \Upload::get_files();
foreach ($files as $file) {
$result[$file['field']] = $file;
}
$is_upload = true;
} else {
$error_files = \Upload::get_errors();
foreach ($error_files as $file) {
foreach ($file['errors'] as $error) {
if ($error['error'] != \Upload::UPLOAD_ERR_NO_FILE) {
$result[$file['field']] = $file;
$is_upload = false;
}
}
}
if (empty($result)) {
$is_upload = true;
}
}
return array($is_upload, $result);
}
示例2: action_create
public function action_create()
{
if (Input::method() == 'POST') {
$config = array('path' => DOCROOT . DS . 'files', 'randomize' => true, 'ext_whitelist' => array('txt'));
Upload::process($config);
if (Upload::is_valid()) {
$file = Upload::get_files(0);
$contents = File::read($file['file'], true);
foreach (explode("\n", $contents) as $line) {
if (preg_match('/record [0-9]+ BAD- PHONE: ([0-9]+) ROW: \\|[0-9]+\\| DUP: [0-9] [0-9]+/i', $line, $matches)) {
$all_dupes[] = $matches[1];
}
}
$dupe_check = \Goautodial\Insert::duplicate_check($all_dupes);
foreach ($dupe_check as $dupe_number => $dupe_details) {
$new_duplicate = new Model_Data_Supplier_Campaign_Lists_Duplicate();
$new_duplicate->list_id = Input::post('list_id');
$new_duplicate->database_server_id = Input::post('database_server_id');
$new_duplicate->duplicate_number = $dupe_number;
$new_duplicate->dialler = $dupe_details['dialler'];
$new_duplicate->lead_id = $dupe_details['data']['lead_id'];
$new_duplicate->save();
}
} else {
print "No Uploads";
}
}
$this->template->title = "Data_Supplier_Campaign_Lists_Duplicates";
$this->template->content = View::forge('data/supplier/campaign/lists/duplicates/create');
}
示例3: action_create
public function action_create()
{
if (Input::method() == 'POST') {
$val = Model_Syllabus::validate('create');
if ($val->run()) {
$syllabus = Model_Syllabus::forge(array('title' => Input::post('title'), 'file_url' => Input::post('file_url'), 'subject_id' => Input::post('subject_id')));
$sourceDoc = '';
foreach (Upload::get_files() as $file) {
$sourceDoc = $file['file'];
break;
}
if (!($syllabus->file_url = Helper_GoogleDrive::createFile(Input::post('title'), Auth::get('email'), $sourceDoc))) {
Session::set_flash('error', e('Could not created an online document.'));
} else {
if ($syllabus and $syllabus->save()) {
Session::set_flash('success', e('Added syllabus #' . $syllabus->id . '.'));
Response::redirect('site/syllabuses');
} else {
Session::set_flash('error', e('Could not save syllabus.'));
}
}
} else {
Session::set_flash('error', $val->error());
}
}
$subjects = Model_Subject::getSubjectOptions();
$this->template->set_global('subjects', $subjects, false);
$this->template->title = "Syllabuses";
$this->template->content = View::forge('site/syllabuses/create');
}
示例4: post_parse_payments
public function post_parse_payments()
{
$config = array('path' => DOCROOT . 'uploads/csv', 'randomize' => true, 'ext_whitelist' => array('csv'));
Upload::process($config);
if (Upload::is_valid()) {
//Upload::save();
$file = Upload::get_files();
$uploaded_file = $file[0]['file'];
Package::load("excel");
$excel = PHPExcel_IOFactory::createReader('CSV')->setDelimiter(',')->setEnclosure('"')->setLineEnding("\n")->setSheetIndex(0)->load($uploaded_file);
$objWorksheet = $excel->setActiveSheetIndex(0);
$highestRow = $objWorksheet->getHighestRow();
$highestColumn = $objWorksheet->getHighestColumn();
$highestColumnIndex = PHPExcel_Cell::columnIndexFromString($highestColumn);
//read from file
for ($row = 1; $row <= $highestRow; ++$row) {
$file_data = array();
for ($col = 0; $col <= $highestColumnIndex; ++$col) {
$value = $objWorksheet->getCellByColumnAndRow($col, $row)->getValue();
$file_data[$col] = trim($value);
}
$result[] = $file_data;
}
print_r($result);
} else {
print "Invalid uploads";
}
}
示例5: action_commit
public function action_commit()
{
$item = new Model_Item();
$item->name = $_POST['item_name'];
$item->phonetic = $_POST['phonetic'];
$item->category = $_POST['category'];
if ($_POST['category'] == 'ピザ') {
$item->unit_price_s = $_POST['s_money'];
$item->unit_price_m = $_POST['m_money'];
$item->unit_price_l = $_POST['l_money'];
} else {
$item->unit_price = $_POST['money'];
}
$item->explanatory = $_POST['explanation'];
$item_img = new Model_Itemimg();
// 初期設定
$config = array('path' => DOCROOT . DS . 'assets/img', 'randomize' => true, 'ext_whitelist' => array('img', 'jpg', 'jpeg', 'gif', 'png'));
// アップロード基本プロセス実行
Upload::process($config);
// 検証
if (Upload::is_valid()) {
// 設定を元に保存
Upload::save();
$uploadfile = Upload::get_files(0);
// 情報をデータベースに保存する場合
$item_img->path = $uploadfile["name"];
}
foreach (Upload::get_errors() as $file) {
// $file['errors']の中にエラーが入っているのでそれを処理
}
$item_img->save();
$item->img_id = $item_img->id;
$item->save();
return View::forge('top/top');
}
示例6: action_index
public function action_index()
{
$is_chenged = false;
if ($this->user->bank == null) {
$this->user->bank = Model_Bank::forge();
$this->user->bank->user_id = $this->user->id;
$this->user->bank->save();
}
if (Input::post("firstname", null) != null and Security::check_token()) {
$email = Input::post("email", null);
if ($email != $this->user->email) {
$check_user = Model_User::find("first", ["where" => [["email" => $email]]]);
if ($check_user == null) {
$this->email = $email;
} else {
$data["error"] = "This email is already in use.";
}
}
$config = ["path" => DOCROOT . "assets/img/pictures/", 'randomize' => true, 'auto_rename' => true, 'ext_whitelist' => array('img', 'jpg', 'jpeg', 'gif', 'png')];
Upload::process($config);
if (Upload::is_valid()) {
Upload::save();
$saved_result = Upload::get_files();
$file_name = $saved_result[0]['saved_as'];
$image = Image::load($config["path"] . $file_name);
$image->crop_resize(200, 200)->save($config["path"] . "m_" . $file_name);
$image->crop_resize(86, 86)->save($config["path"] . "s_" . $file_name);
$this->user->img_path = $file_name;
} else {
$error = Upload::get_errors();
}
if (!isset($data["error"])) {
$this->user->firstname = Input::post("firstname", "");
$this->user->middlename = Input::post("middlename", "");
$this->user->lastname = Input::post("lastname", "");
$this->user->google_account = Input::post("google_account", "");
$this->user->pr = Input::post("pr", "");
$this->user->educational_background = Input::post("educational_background", "");
$this->user->enchantJS = Input::post("enchantJS", 0);
$this->user->trial = Input::post("trial", 0);
$this->user->save();
$this->user->bank->name = Input::post("bank_name", "");
$this->user->bank->branch = Input::post("bank_branch", "");
$this->user->bank->account = Input::post("bank_account", "");
$this->user->bank->number = Input::post("bank_number", "");
$this->user->bank->etc = Input::post("bank_etc", "");
$this->user->bank->type = Input::post("bank_type", 0);
$this->user->bank->save();
$is_chenged = true;
}
}
$data["user"] = $this->user;
$data["is_chenged"] = $is_chenged;
$view = View::forge("teachers/profile", $data);
$this->template->content = $view;
}
示例7: upload
public function upload()
{
$arrFile = array();
if ($_FILES['file_process_data']['name']) {
if (\Upload::is_valid()) {
\Upload::save();
$fileName = current(\Upload::get_files());
$arrFile['file_process_data'] = $fileName['saved_as'];
}
}
return $arrFile;
}
示例8: action_update
public function action_update($username = 'k000c0000')
{
//バリデーション定義
$val = Validation::forge();
//ニックネームは必須で、最大文字数は50文字以内
$val->add('name', '「ニックネーム」')->add_rule('required')->add_rule('max_length', 50);
//メールアドレスは必須で、入力内容がメールの形式に沿っているか
$val->add('email', '「メールアドレス」')->add_rule('required')->add_rule('valid_email');
$class = Auth::get('classID');
//ログイン中の学生のレコードを取得する
$user = Model_Users::find($username);
//各カラムに更新情報を格納する
$user->fullname = Input::post('name');
$user->email = Input::post('email');
//アップロードファイルがバリデーション通りなら投稿内容保存
if (Upload::is_valid()) {
//設定を元に保存をする
Upload::save();
foreach (Upload::get_files() as $file) {
$user->icon = $file['saved_as'];
}
}
if ($val->run()) {
$user->save();
//更新後のレコードを取得する
$this->data['users'] = Model_Users::query()->where('username', '=', $username)->get();
$this->data['classname'] = Model_Class::query()->where('classID', '=', $class)->get();
$this->action_categorise();
//ビューオブジェクトの作成
$view = View::forge('changeregistration/ChangeRegistration', $this->data);
//ビューのmessage変数に更新成功時のメッセージを定義
$this->message = '登録内容を変更しました。';
//ビューに渡す変数をセットメソッドで定義する
$view->set_global('message', $this->message, false);
$view->set_global('error', $this->error, false);
} else {
//現在のレコードを取得する
$this->data['users'] = Model_Users::query()->where('username', '=', $username)->get();
$this->data['classname'] = Model_Class::query()->where('classID', '=', $class)->get();
$this->action_categorise();
//バリデーションからエラーメッセージを取得する
$this->error = $val->error();
//ビューオブジェクト生成
$view = View::forge('changeregistration/ChangeRegistration', $this->data);
//ビューに渡す変数をセットメソッドで定義する
$view->set_global('message', $this->message, false);
$view->set_global('error', $this->error, false);
}
//ビューを返す
return $view;
}
示例9: update_item
public function update_item($post_data)
{
$upload_type = $this->def('upload_type', 'image');
$upload_dir = \Config::get($upload_type . '_dir', 'files');
$files = \Upload::get_files();
$clean_class = str_replace('\\', '', $this->class);
foreach ($files as $key => $params) {
if ($params['field'] == $clean_class . '-' . ($this->item->id ? $this->item->id : 'new') . "-{$this->field}") {
$idx = $key;
break;
}
}
if (isset($idx)) {
\Upload::save(array($idx), $this->def('secure') ? realpath(\Config::get('secure_dir', 'secure') . $upload_dir) : DOCROOT . $upload_dir);
$errors = \Upload::get_errors();
if (!isset($errors[$idx])) {
$files = \Upload::get_files();
$name = $files[$idx]['saved_as'];
$path = $files[$idx]['saved_to'];
if ($upload_type == 'image') {
if ($dimensions = $this->def('dimension')) {
// resize image
$image = \Image::load($path . $name);
foreach ($dimensions as $dim) {
if (preg_match("/^(?P<width>[0-9]+)x(?P<height>[0-9]+)\$/i", $dim, $matches)) {
$image->resize($matches['width'], $matches['height'])->save_pa(null, strtolower("_{$dim}"));
}
}
}
} elseif ($upload_type == 'audio') {
if ($lengths = $this->def('truncate')) {
if ($ffmpeg = \Config::get('ffmpeg')) {
foreach ($lengths as $len) {
// truncate audio track
$sample = preg_replace("/^(.+)\\.([^\\.]+)\$/", '$1_sample_' . $len . '.$2', $name);
// TODO: make an ffmpeg wrapper class
shell_exec("{$ffmpeg} -i " . escapeshellarg($path . $name) . " -t {$length} -acodec copy " . escapeshellarg(DOCROOT . $upload_dir . DS . $sample));
}
} else {
error_log("could not truncate audio: ffmpeg not configured.");
}
}
}
$this->item->{$this->field} = $name;
} else {
error_log(print_r($errors, true));
return array('upload_error' => $this->def('desc') . ' failed to save. Error No. ' . $errors[$idx]['error']);
}
}
return true;
}
示例10: action_add_letterhead
public function action_add_letterhead()
{
$validation = Validation::forge();
if ($validation->run()) {
$config = array('path' => \Subpackage\Subconfig::get(static::$_configFile . '.letterhead_directory'), 'randomize' => true, 'ext_whitelist' => array('pdf'));
Upload::process($config);
if (Upload::is_valid()) {
Upload::save();
$filename = Upload::get_files();
$insertID = Model_Letterhead::create(Input::post('letterhead_title'), Input::post('letterhead_description'), Input::post('letterhead_company'), $filename[0]['saved_as'], array('top' => Input::post('letterhead_margin_top'), 'bottom' => Input::post('letterhead_margin_bottom'), 'left' => Input::post('letterhead_margin_left'), 'right' => Input::post('letterhead_margin_right')), Input::post('letterhead_product'));
print "Added Letterhead with ID: " . $insertID;
}
}
$this->template->title = 'Add Letterhead : Letter Management';
$this->template->content = View::forge(static::$_viewPath . 'manage/add_letterhead.php', array('companies' => \Crm\Company\Company_model::companyList()));
}
示例11: action_update
public function action_update($Pid = 0)
{
$username = Auth::get_screen_name();
$this->data['token_key'] = Config::get('security.csrf_token_key');
$this->data['token'] = Security::fetch_token();
if (Security::check_token()) {
$val = Model_Post::validate();
if ($val->run()) {
$post = Model_Post::find($Pid);
$post->class = Input::post('cla');
$post->Title = Input::post('title');
$post->Pcontent = Input::post('Pcontent');
$post->Kid = Input::post('category');
Upload::process();
if (Upload::is_valid()) {
//設定を元に保存をする
Upload::save();
foreach (Upload::get_files() as $file) {
$post->image = $file['saved_as'];
}
}
$post->save();
$this->action_categorize();
$this->data['users'] = Model_Users::query()->where('username', '=', $username)->get();
$this->data['posts'] = Model_Post::query()->where('username', '=', $username)->order_by('Ptime', 'desc')->get();
$message = '投稿内容を変更しました。';
$view = View::forge('mypage/mypage', $this->data);
$view->username = $username;
$view->set_global('message', $message, false);
$view->set_global('error', $this->error, false);
//バリデーションエラー
} else {
$this->action_categorize();
$Pid and $this->data['posts'] = DB::select()->from('Post')->where('Pid', '=', $Pid)->execute();
$view = View::forge('post/PostEdit', $this->data);
$this->error = $val->error();
$view->username = $username;
$view->set_global('error', $this->error, false);
}
} else {
Profiler::mark('CSRFだー!');
}
return $view;
}
示例12: action_upload
public function action_upload($folder, $sub = null)
{
if (\Fuel\Core\Input::method() == 'POST') {
try {
\Fuel\Core\DB::start_transaction();
$val = Model_Filemanager::validate('create');
if ($val->run()) {
$config = array('path' => "/var/www/html/" . $this->_dir . "/" . $folder . "/" . $sub . DS, 'ext_whitelist' => array('jpg', 'jpeg', 'png'), 'file_chmod' => 0777, 'auto_rename' => true, 'overwrite' => true, 'randomize' => true, 'create_path' => true);
Upload::process($config);
$img = '';
if (Upload::is_valid()) {
Upload::save();
$img = Upload::get_files()[0];
}
if (!\Fuel\Core\Input::post('id')) {
$file = Model_Filemanager::forge(array('folder' => $folder, 'key' => Input::post('key'), 'value' => $img['saved_as'], 'photographer' => \Fuel\Core\Input::post('photographer'), 'price' => \Fuel\Core\Input::post('price'), 'usage' => \Fuel\Core\Input::post('usage'), 'source' => \Fuel\Core\Input::post('source')));
} else {
$file = Model_Filemanager::find_by_id(\Fuel\Core\Input::post('id'));
if ($img == '') {
$img = $file->value;
}
if ($file) {
$file->set(array('folder' => $folder, 'key' => Input::post('key'), 'value' => $img, 'photographer' => \Fuel\Core\Input::post('photographer'), 'price' => \Fuel\Core\Input::post('price'), 'usage' => \Fuel\Core\Input::post('usage'), 'source' => \Fuel\Core\Input::post('source')));
} else {
throw new Exception('File not found!');
}
}
if ($file and $file->save()) {
DB::commit_transaction();
\Fuel\Core\Session::set_flash('success', 'Upload success');
} else {
throw new Exception('Cannot save into database!');
}
} else {
throw new Exception($val->show_errors());
}
} catch (Exception $e) {
DB::rollback_transaction();
\Fuel\Core\Session::set_flash('error', $e->getMessage());
}
}
\Fuel\Core\Response::redirect(\Fuel\Core\Uri::create('filemanager/folder/' . $folder));
}
示例13: action_do_upload
public function action_do_upload()
{
logger('1', 'Starting upload');
\Upload::process(array('path' => './uploads', 'normalize' => true, 'change_case' => 'lower'));
logger('1', 'Finished upload');
echo "<pre>";
print_r(\Upload::get_files());
print_r(\Upload::get_errors());
logger('1', 'Errors: ' . serialize(\Upload::get_errors()));
echo \Upload::is_valid() ? "<span style='color: green; font-weight: bold;'>VALID</span>" : "<span style='color: red; font-weight: bold;'>ERROR</span>";
echo '<br><br><br>';
\Upload::save();
echo 'Valid:<br>';
print_r(\Upload::get_files());
logger('1', 'Valid uploads: ' . serialize(\Upload::get_files()));
echo '<br>Errors:<br>';
print_r(\Upload::get_errors());
echo "</pre>";
}
示例14: action_register
public function action_register()
{
if (Input::method() == 'POST') {
$val = Model_User::validate('create');
if ($val->run()) {
$user = Model_User::forge(array('username' => Input::post('username'), 'password' => Auth::instance()->hash_password(Input::post('password')), 'group' => 1, 'email' => Input::post('email'), 'fname' => Input::post('fname'), 'mname' => Input::post('mname'), 'lname' => Input::post('lname'), 'contact_num' => Input::post('contact_num'), 'address' => Input::post('address'), 'profile_pic' => Input::post('profile_pic'), 'last_login' => Input::post('last_login'), 'login_hash' => Input::post('login_hash'), 'profile_fields' => Input::post('profile_fields')));
Upload::process(Config::get('upload_profile_picture'));
$user->profile = Model_Student::forge(['year_level' => 0, 'course_id' => 0]);
if (Upload::is_valid()) {
Upload::save();
$value = Upload::get_files();
foreach ($value as $files) {
$user->profile_pic = $value[0]['saved_as'];
}
if ($user and $user->save()) {
Session::set_flash('success', e('Succesfully Added user #' . $user->id . '.'));
Response::redirect('site/login');
} else {
Session::set_flash('error', e('Could not save user.'));
}
} else {
Session::set_flash('error', e('Uploaded photo is invalid.'));
}
// if ($user and $user->save())
// {
// Session::set_flash('success', e('Succesfully Added user #'.$user->id.'.'));
// Response::redirect('site/login');
// }
// else
// {
// Session::set_flash('error', e('Could not save user.'));
// }
} else {
Session::set_flash('error', $val->error());
}
}
// $this->template->title = "Users";
// $this->template->content = View::forge('admin/users/create');
$this->template->title = 'Register';
$this->template->content = View::forge('site/register');
}
示例15: action_file
public function action_file($table_name)
{
// Find class name and metadata etc
$class_name = \Admin::getClassForTable($table_name);
if ($class_name === false) {
return $this->show404(null, "type");
}
// Don't continue if no files have been uploaded
if (!count(\Upload::get_files())) {
\Session::set_flash('main_alert', array('attributes' => array('class' => 'alert-danger'), 'msg' => \Lang::get('admin.errors.upload.no_files')));
\Response::redirect_back("/admin/{$table_name}");
}
// Ensure directory exists
$path = DOCROOT . 'uploads/imports';
if (!is_dir($path)) {
@mkdir($path, 0775, true);
}
if (!is_dir($path)) {
\Session::set_flash('main_alert', array('attributes' => array('class' => 'alert-danger'), 'msg' => \Lang::get('admin.errors.upload.directory_not_created')));
return;
}
// Process the uploaded file
\Upload::process(array('path' => $path, 'auto_rename' => false, 'overwrite' => true, 'normalize' => true, 'ext_whitelist' => array('xlsx', 'xls', 'xml', 'csv', 'json')));
// Save it to the filesystem if valid
if (\Upload::is_valid()) {
\Upload::save();
}
// Import the file
$file = \Upload::get_files(0);
$file_path = \Arr::get($file, 'saved_to') . \Arr::get($file, 'saved_as');
$this->import_result = \CMF\Utils\Importer::importFile($file_path, $class_name);
// If success, redirect back with message
if (isset($this->import_result['success']) && $this->import_result['success']) {
\Session::set_flash('main_alert', array('attributes' => array('class' => 'alert-success'), 'msg' => isset($this->import_result['message']) ? $this->import_result['message'] : \Lang::get('admin.messages.import_success')));
\Response::redirect("/admin/{$table_name}", 'location');
}
// No success, damn!
\Session::set_flash('main_alert', array('attributes' => array('class' => 'alert-danger'), 'msg' => isset($this->import_result['message']) ? $this->import_result['message'] : \Lang::get('admin.errors.actions.import')));
\Response::redirect_back("/admin/{$table_name}");
}