public function addUser() { if (IS_POST) { //上传头像的路径 $path = 'Upload/UserImages/' . date("Y/m/d"); $data = $_POST; $data['password'] = md5($data['password']); $data['create_time'] = time(); $user = K('User'); if (!$user->valid($data['username'])) { if (isset($_FILES['user_img'])) { $upload = new Upload($path); $files = $upload->upload(); } $data['user_img'] = $files[0]['path']; if ($user->addUser($data)) { $this->success('用户添加成功!', U('listUser', array('p' => 1))); } else { $this->error('用户添加失败了,请检查填写信息!', U('addUser')); } } else { $this->error('用户添加失败,请检查填写信息!', U('addUser')); } } $this->display(); }
/** * 首页 * */ public function action_index() { if (!empty($_FILES)) { $savePath = DOCROOT . 'src_csv/' . $this->auth['uid'] . '/'; // 保存目录 $upload = new Upload(array('size' => 10240, 'ext' => array('csv'))); $upload->set_path($savePath); try { $result = $upload->save($_FILES['upload_file']); $date = array($this->auth['uid'], $this->auth['username'], $result['name'], $result['saveName'], $result['size'], date('Y-m-d H:i:s')); $row = DB::insert('imgup_movestore', array('uid', 'uname', 'csv_file', 'src_file', 'freesize', 'upload_time'))->values($date)->execute(); $content = $this->changeCharacter($savePath . $result['saveName']); //preg_match_all("/(src)=[\"|'| ]{0,}((https?\:\/\/.*?)([^>]*[^\.htm]\.(gif|jpg|bmp|png)))/i",$content, $match); //preg_match_all("/[\"|'| ]{0,}((https?\:\/\/[a-zA-Z0-9_\.\/]*?)([^<\>]*[^\.htm]\.(gif|jpg|bmp|png)))/i", $content, $match); preg_match_all("/\\<img.*?src\\=[\"\\']+[ \t\n]*(https?\\:\\/\\/.*?)[ \t\n]*[\"\\']+[^>]*>/i", $content, $match); $imgArr = array_unique($match[1]); foreach ($imgArr as $value) { # 去除本站的图片地址 if (!preg_match("/^http:\\/\\/[\\w\\.\\-\\_]*wal8\\.com/i", $value)) { DB::insert('store_imgs', array('sid', 'url', 'add_time', 'uid'))->values(array($row[0], $value, time(), $this->auth['uid']))->execute(); } } $link[] = array('text' => '返回', 'href' => '/shopmove'); $this->show_message('上传' . $result['name'] . '文件成功', 1, $link); } catch (Exception $e) { $link[] = array('text' => '返回', 'href' => '/shopmove'); $this->show_message($e->getMessage(), 0, $link); } } }
/** * 编辑器文件上传 */ public function actionUpload() { if (XUtils::method() == 'POST') { $file = XUpload::upload($_FILES['imgFile']); if (is_array($file)) { $model = new Upload(); $model->user_id = intval($admini['userId']); $model->file_name = CHtml::encode($file['pathname']); $model->thumb_name = CHtml::encode($file['paththumbname']); $model->real_name = CHtml::encode($file['name']); $model->file_ext = $file['extension']; $model->file_mime = $file['type']; $model->file_size = $file['size']; $model->save_path = $file['savepath']; $model->hash = $file['hash']; $model->save_name = $file['savename']; $model->create_time = time(); if ($model->save()) { exit(CJSON::encode(array('error' => 0, 'url' => Yii::app()->baseUrl . '/' . $file['pathname']))); } else { @unlink($file['pathname']); @unlink($file['paththumbname']); exit(CJSON::encode(array('error' => 1, 'message' => '上传错误'))); } } else { exit(CJSON::encode(array('error' => 1, 'message' => '上传错误:' . $file))); } } }
function createquestion($params, $file_name = '') { //print_r($_FILES); //exit(); if ($file_name != '') { $upload = new Upload($file_name, '../lib/uploads/', 5242880); $upload->file_prefix = 'closeup_' . $this->rand_string(); $upload_result = $upload->upload_process(); if ($upload->upload_error) { $response = $upload->upload_error; } else { $params['filename'] = $upload_result['name']; $fields = array_keys($params); $values = $params; $tablename = "questions"; $response = $this->InsertOpt($tablename, $fields, $values); } } else { $fields = array_keys($params); $values = $params; $tablename = "questions"; $response = $this->InsertOpt($tablename, $fields, $values); } return $response; }
public function share_validation() { $this->load->library('form_validation'); $this->load->helper('form'); $this->form_validation->set_error_delimiters('<div class="alert alert-error"><button type="button" class="close" data-dismiss="alert">×</button>', '</div>'); //mise en place des regles $this->form_validation->set_rules('keywords', 'Mots-clés', 'required|encode_php_tags|htmlspecialchars|trim|xss_clean|max_length[200]'); $this->form_validation->set_rules('description', 'Description', 'required|encode_php_tags|htmlspecialchars|trim|xss_clean|max_length[300]'); if ($this->form_validation->run() == FALSE) { //on affiche le formulaire $this->share(); } else { // upload du fichier $file_up = new Upload(); $user = unserialize($this->session->userdata('user_obj')); if ($file_up->upload_file($user->id, array('userfile'))) { // Création fichier $file = new File(); $file->id_user = $user->id; $file->desc = $this->input->post('description'); $file->keywords = $this->input->post('keywords'); $file->url = $file_up->files_uploaded[0][0]; $file->type = $file_up->files_uploaded[0][1]; //sauvegarde du fichier $file->save(); //notification $this->session->set_userdata('notif_ok', '<div class="alert alert-success"><button type="button" class="close" data-dismiss="alert">×</button><strong>Bravo! </strong> Votre partage a été réussi.</div>'); //redirection sur l'actualité redirect('flux', 'refresh'); } else { //on affiche le formulaire $this->share(); } } }
/** * 文件上传 * @param array $files 要上传的文件列表(通常是$_FILES数组) * @param array $setting 文件上传配置 * @param string $driver 上传驱动名称 * @param array $config 上传驱动配置 * @return array 文件上传成功后的信息 */ public function upload($files, $setting, $driver = 'Local', $config = null) { $setting['callback'] = array($this, 'isFile'); $setting['removeTrash'] = array($this, 'removeTrash'); $Upload = new Upload($setting, $driver, $config); $info = $Upload->upload($files); if ($info) { //文件上传成功,记录文件信息 foreach ($info as $key => &$value) { /* 已经存在文件记录 */ if (isset($value['id']) && is_numeric($value['id'])) { continue; } /* 记录文件信息 */ $value['path'] = substr($setting['rootPath'], 1) . $value['savepath'] . $value['savename']; //在模板里的url路径 if ($this->create($value) && ($id = $this->add())) { $value['id'] = $id; } // else { // //TODO: 文件上传成功,但是记录文件信息失败,需记录日志 // unset($info[$key]); // } } return $info; //文件上传成功 } else { $this->error = $Upload->getError(); return false; } }
/** * Uploadify上传文件处理 */ public function hd_uploadify() { $uploadModel = M('upload'); //上传文件类型 if (isset($_POST['type'])) { $type = str_replace('*.', '', $_POST['type']); $type = explode(';', $type); } else { $type = array(); } $size = Q('size') ? Q('size') : C('allow_size'); $upload = new Upload(Q('upload_dir'), $type, $size); $file = $upload->upload(); if (!empty($file)) { $file = $file[0]; $file['uid'] = $_SESSION['user']['uid']; //图片加水印 if ($file['image'] && Q('water')) { $img = new Image(); $img->water($file['path']); } //写入upload表 $uploadModel->add($file); $data = $file; $data['status'] = 1; } else { $data['status'] = 0; $data['message'] = $upload->error; } echo json_encode($data); exit; }
return $this->db->lastInsertId(); } /** * Update image */ public function updateImage($id) { $ruler = new Ruler($id); if ($ruler->Background == null) { return false; } require_once 'core/class.upload/class.upload.php'; $templates = DIR_DBIMAGES . 'ruler/templates/'; $results = DIR_DBIMAGES . 'ruler/results/'; $iu = new Upload($templates . $ruler->Background); $iu->file_overwrite = true; $iu->file_new_name_body = $id; $iu->file_new_name_ext = 'jpg'; $iu->image_unsharp = true; $iu->image_border = '0 0 16 0'; $iu->image_border_color = strtolower($ruler->Color) == '#ffffff' ? '#333333' : '#ffffff'; $iu->image_watermark = $templates . $ruler->Slider; $iu->image_watermark_y = 35; $iu->image_watermark_x = $ruler->getSliderPosition(); $iu->Process($results); $image = imagecreatefromjpeg($results . $id . '.jpg');
/** * Upload the file and store * the file path in the DB. */ public function store() { // Rules $rules = array('name' => 'required', 'file' => 'required|max:20000'); $messages = array('max' => 'Please make sure the file size is not larger then 20MB'); // Create validation $validator = Validator::make(Input::all(), $rules, $messages); if ($validator->fails()) { return Redirect::back()->withErrors($validator)->withInput(); } $directory = "uploads/files/"; // Before anything let's make sure a file was uploaded if (Input::hasFile('file') && Request::file('file')->isValid()) { $current_file = Input::file('file'); $filename = Auth::id() . '_' . $current_file->getClientOriginalName(); $current_file->move($directory, $filename); $file = new Upload(); $file->user_id = Auth::id(); $file->project_id = Input::get('project_id'); $file->name = Input::get('name'); $file->path = $directory . $filename; $file->save(); return Redirect::back(); } $upload = new Upload(); $upload->user_id = Auth::id(); $upload->project_id = Input::get('project_id'); $upload->name = Input::get('name'); $upload->path = $directory . $filename; $upload->save(); return Redirect::back(); }
public function profileActAction() { $m['realname'] = $this->getPost('realname'); $m['provinceID'] = $this->getPost('areaProvince'); $m['cityID'] = $this->getPost('areaCity'); $m['regionID'] = $this->getPost('areaRegion'); $m['province'] = $this->load('Province')->getProvinceNameByID($m['provinceID']); $m['city'] = $this->load('City')->getCityNameByID($m['cityID']); if ($m['regionID']) { $m['region'] = $this->load('Region')->getRegionNameByID($m['regionID']); } $code = $this->m_user->UpdateByID($m, USER_ID); // Upload avatar if selected if ($_FILES['avatar']['name']) { $fileName = CUR_TIMESTAMP; $up = new Upload($_FILES['avatar'], UPLOAD_PATH . '/'); $result = $up->upload($fileName); if ($result == 1) { $m['avatar'] = $fileName . '.' . $up->extension; $this->m_user->UpdateByID($m, USER_ID); } else { jsAlert($result); } } if (FALSE === $code && $result != 1) { jsAlert('编辑个人信息失败, 请重试'); } $this->redirect('/user/profile/edit'); }
public function addphotoAction() { $db = new Db(); $this->view->pageHeading = "What are you wearing today?"; if ($this->getRequest()->isPost()) { $request = $this->getRequest(); $myform = new Form_Upload(); if ($myform->isValid($request->getPost())) { $dataForm = $myform->getValues(); $myObj = new Upload(); $Result = $myObj->SaveImage($dataForm); if ($Result == 1) { //echo "dsg"; die; $mySession->sucessMsg = "Image saved successfully."; $this->_redirect('post/uploadindex'); } else { $mySession->errorMsg = "Image you have entered already exists."; $this->view->myform = $myform; $this->render('upload'); } } else { $this->view->myform = $myform; $this->render('upload'); } } else { $this->_redirect('post/upload'); } }
/** * Uploadify上传文件处理 */ public function hd_uploadify() { $uploadModel = M('upload'); //开启裁切 C('UPLOAD_IMG_RESIZE_ON', true); C('upload_img_max_width', $_POST['upload_img_max_width']); C('upload_img_max_height', $_POST['upload_img_max_height']); $upload = new Upload(Q('post.upload_dir'), array(), array(), Q("water", null, "intval")); $file = $upload->upload(); if (!empty($file)) { $file = $file[0]; $file['uid'] = session('uid'); $data['stat'] = 1; $data['url'] = __ROOT__ . '/' . $file['path']; $data['path'] = $file['path']; $data['filename'] = $file['filename']; $data['name'] = $file['name']; $data['basename'] = $file['basename']; $data['thumb'] = array(); $data['isimage'] = $file['image']; //写入upload表 $uploadModel->add($file); } else { $data['stat'] = 0; $data['msg'] = $upload->error; } echo json_encode($data); exit; }
public function replace($id = null) { if (!get('_csrf') or !csrf(get('_csrf'))) { return response::error('unauthenticated access'); } $filename = get('filename'); $file = $this->file($id, $filename); $blueprint = blueprint::find($this->page($id)); $upload = new Upload($file->root(), array('overwrite' => true, 'accept' => function ($upload) use($file) { if ($upload->mime() != $file->mime()) { throw new Error(l('files.replace.error.type')); } })); if ($file = $upload->file()) { try { $this->checkUpload($file, $blueprint); kirby()->trigger('panel.file.replace', $file); return response::success('success'); } catch (Exception $e) { $file->delete(); return response::error($e->getMessage()); } } else { return response::error($upload->error()->getMessage()); } }
function asignar_cotizacion($id_equipo, $placa_inventario) { App::import('Vendor', 'upload', array('file' => 'class.upload.php')); $this->autoLayout = false; $this->autoRender = false; $datos_json = array('resultado' => false, 'id' => '', 'nombre_archivo' => ''); if (!empty($_FILES) && !empty($id_equipo) && !empty($placa_inventario)) { if (!empty($_FILES['cotizacion']['name'])) { $handle = new Upload($_FILES['cotizacion']); if ($handle->uploaded) { $handle->file_overwrite = true; $handle->file_safe_name = false; $handle->file_auto_rename = false; $handle->file_new_name_body = 'cotizacion(' . $this->Cotizacion->getNextAutoIncrement() . ')_' . $placa_inventario; $handle->Process('equipos/cotizaciones'); if ($handle->processed) { $this->data['Cotizacion']['nombre_archivo'] = $handle->file_dst_name; $this->data['Cotizacion']['id_equipo'] = $id_equipo; $this->data['Cotizacion']['placa_inventario'] = $placa_inventario; if ($this->Cotizacion->save($this->data)) { $datos_json['resultado'] = true; $datos_json['id'] = $this->Cotizacion->id; $datos_json['nombre_archivo'] = $this->data['Cotizacion']['nombre_archivo']; } } $handle->Clean(); } } } return json_encode($datos_json); }
public function addHander() { // p($_FILES); // p($_POST); preg_match_all('/<\\s*img\\s+[^>]*?src\\s*=\\s*(\'|\\")(.*?)\\">/i', $_POST['details'], $result, PREG_SET_ORDER); $dir = MYPHP_TEMP_PATH . "/Article/" . $_POST['column_id'] . '/' . $_POST['category_id']; is_dir($dir) || mkdir($dir, 0777, true); chmod($dir, 0777); $aid = (int) file_get_contents(MYPHP_TEMP_PATH . '/Dbid/Article/Article/dbid.txt'); $fileName = $dir . '/' . date('Y-m-d') . '-' . $_POST['column_id'] . '-' . $_POST['category_id'] . '-' . ($aid + 1) . '.txt'; $data = array(); foreach ($result as $v) { $data[] = $v[0]; } // p($fileName);die; file_put_contents($fileName, serialize($data)); $details = preg_replace('/<\\s*img\\s+[^>]*?src\\s*=\\s*(\'|\\")(.*?)\\">/i', "<baseImg/>", $_POST['details']); if (isset($_FILES['thumb'])) { $upload = new Upload('Upload/Article/images/' . date("Y/m/d")); $files = $upload->upload(); } // p($files); // die; $articleData = array('column_id' => $_POST['column_id'], 'category_id' => $_POST['category_id'], 'title' => $_POST['title'], 'tags' => $_POST['tags'], 'recommend' => $_POST['recommend'], 'author' => isset($_POST['author']) ? $_POST['author'] : $_SESSION['uname'], 'source' => $_POST['source'], 'details' => $_POST['details'], 'display' => $_POST['display'], 'thumb' => empty($files[0]['path']) ? "" : $files[0]['path'], 'image' => $fileName, 'create_time' => time()); $articleData['details'] = $details; if (K('Article')->addArticle($articleData)) { $this->success('文章添加成功', __APP__ . '?c=Article&a=listArticle'); } else { $this->error('文章添加失败'); } }
/** * 文件不是以base64方式上传 * @param type $path * @param type $filename * @param type $file * @return type */ function fileupload($path, $filename, $file) { header("Expires: Mon, 26 Jul 1990 05:00:00"); //表示永远过期 header("Last-Modified: " . date("D, d M Y H:i:s")); header("Cache-Control: no-store, no-cache, must-revalidate"); //不使用缓存 header("Cache-Control: post-check=0, pre-check=0", false); //不使用缓存 header("Pragma: no-cache"); //不使用缓存 $upload = new Upload(); // 实例化上传类 $upload->rootPath = $path; // 设置附件上传根目录 $upload->savePath = ""; // 设置附件上传(子)目录 $var_extend = explode(".", $filename); if (count($var_extend) == 1) { $upload->saveName = $filename; } else { $varExt = "." . $var_extend[count($var_extend) - 1]; $varlength = 0 - strlen($varExt); $upload->saveName = substr($filename, 0, $varlength); } $upload->autoSub = false; // 上传文件 $fileCallback = array("flag" => true, "error" => "", "filename" => $filename); $flag = $upload->uploadOne($file); if (!$flag) { $fileCallback["flag"] = false; $fileCallback["error"] = $upload->getError(); } return $fileCallback; }
function markdown_upload_ajax_image() { global $zbp; $xhr = array('error' => "", 'url' => ""); foreach ($_FILES as $key => $value) { if ($_FILES[$key]['error'] == 0) { if (is_uploaded_file($_FILES[$key]['tmp_name'])) { $tmp_name = $_FILES[$key]['tmp_name']; $name = $_FILES[$key]['name']; $upload = new Upload(); $upload->Name = $_FILES[$key]['name']; $upload->SourceName = $_FILES[$key]['name']; $upload->MimeType = $_FILES[$key]['type']; $upload->Size = $_FILES[$key]['size']; $upload->AuthorID = $zbp->user->ID; if (!$upload->CheckExtName()) { $xhr['error'] = $this->lang['error'][26]; } if (!$upload->CheckSize()) { $xhr['error'] = $this->lang['error'][27]; } $upload->SaveFile($_FILES[$key]['tmp_name']); $upload->Save(); } } } if (isset($upload)) { CountMemberArray(array($upload->AuthorID), array(0, 0, 0, +1)); $xhr['url'] = $upload->Url; } echo json_encode($xhr); }
/** загрузка(сохранение/обновление) аватара * @param integer ID записи * @param boolean удалять предыдущий аватар * @return имя файла успешно загруженной аватары | false */ function update($nRecordID, $bDeletePrevious = false, $bDoUpdateQuery = false) { global $oDb; if ($nRecordID && !empty($_FILES) && $_FILES[$this->input]['error'] == UPLOAD_ERR_OK) { $oUpload = new Upload($this->input, false); $aImageSize = getimagesize($_FILES[$this->input]['tmp_name']); if ($oUpload->isSuccessfull() && $aImageSize !== FALSE && in_array($aImageSize[2], array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG))) { if ($bDeletePrevious) { $this->delete($nRecordID, false); } $sExtension = func::image_type_to_extension($aImageSize[2], false); $sFilename = Func::generateRandomName($this->filenameLetters, true, true) . '.' . $sExtension; //проверяем размер файла if (!$oUpload->checkSize($this->maxsize)) { return false; } //создаем thumbnail $oThumb = new thumbnail($_FILES[$this->input]['tmp_name']); $oThumb->jpeg_quality(85); $oThumb->crop_proportionaly(1, 1, 'middle', 'center'); $oThumb->createTumbnail_if_more_then($this->path . $nRecordID . '_' . $sFilename, $this->width, $this->height, true); @unlink($_FILES[$this->input]['tmp_name']); if ($bDoUpdateQuery) { $oDb->execute("UPDATE {$this->table} \n SET {$this->fieldAvatar} =" . $oDb->str2sql($sFilename) . "\n WHERE {$this->fieldID} = {$nRecordID} "); } return $sFilename; } } return false; }
/** * @desc sube una imagen jpg al servidor * @param void * @return void */ private function imgUpload() { $msg = ""; $dir = IMG_LOCAL_PATH . "eventos/" . $this->_event_id; $dirweb = IMG_WEB_PATH . "eventos/" . $this->_event_id; $handle = new Upload($_FILES['urlfoto']); if ($handle->uploaded) { // movemos de temp a dir final $handle->Process($dir); // we check if everything went OK if ($handle->processed) { // everything was fine ! $msg .= '!Carga exitosa!: <a href="' . $dirweb . '/' . $handle->file_dst_name . '">' . $handle->file_dst_name . '</a>'; } else { // one error occured $msg .= '<fieldset>'; $msg .= ' <legend>No es posible mover la imagen en la ruta indicada</legend>'; $msg .= ' Error: ' . $handle->error . ''; $msg .= '</fieldset>'; } // we delete the temporary files $handle->Clean(); } else { // if we're here, the upload file failed for some reasons // i.e. the server didn't receive the file $msg .= '<fieldset>'; $msg .= ' <legend>No es pposible cargar la imagen al servidor.</legend>'; $msg .= ' Error: ' . $handle->error . ''; $msg .= '</fieldset>'; } return $msg; }
/** * Uploadify上传文件处理 */ public function hd_uploadify() { $uploadModel = M('upload'); $size = Q('size') ? Q('size') : C('allow_size'); $upload = new Upload(Q('post.upload_dir'), array(), $size); $file = $upload->upload(); if (!empty($file)) { $file = $file[0]; $file['uid'] = session('uid'); //图片加水印 if ($file['image'] && Q('water')) { $img = new Image(); $img->water($file['path']); } //写入upload表 $uploadModel->add($file); $data = $file; $data['status'] = 1; $data['isimage'] = $file['image'] ? 1 : 0; } else { $data['status'] = 0; $data['message'] = $upload->error; } echo json_encode($data); exit; }
protected function pushFile(Upload $file, $attachment = self::CD_INLINE) { header('Cache-Control: maxage=3600'); header('Pragma: public'); header('Content-type: ' . $file->getType()); header('Content-Disposition: ' . $attachment . '; filename="' . $file->getName() . '"'); readfile($file->getFullPath()); }
public function themeImage() { $this->uploader->setRequest(Request::createFromGlobals()); $result = $this->uploader->uploadImageFile(); $file = new File($result['upload_file_id']); $answer = array('file' => array('url' => $file->getUrl(), 'id' => $file->id)); echo json_encode($answer); }
public function testExtension() { $this->instance->init(); $this->instance->serverHandler =& $this->serverHandler; $this->serverHandler->expects($this->once())->method('name')->willReturn('tests/samsonos.png'); $upload = new Upload(array('xls', 'gif'), null, $this->instance); $this->assertFalse($upload->upload()); }
/** * Handles the upload request. This is a static function to ensure that it is easily * accessible to other classes without having to instantiate a {@link Controller} object. * A lot of this code is lifted from {@link AssetAdmin}. * * @todo Error handling on this is crap. * @param SS_HTTPRequest * @param Folder A folder that will be the destination of the upload. * @return array|string */ public static function handle_upload(SS_HTTPRequest $r, $folder = null, $allowed_extensions = null) { if (!$folder) { $folder = singleton('Folder'); } $newFiles = array(); $errorResponse = ""; if (isset($_FILES['file']) && is_array($_FILES['file'])) { $file_array = $_FILES['file']; foreach ($file_array['tmp_name'] as $index => $value) { if (is_uploaded_file($value)) { $tmpFile = array('tmp_name' => $value, 'name' => $file_array['name'][$index], 'size' => $file_array['size'][$index], 'error' => $file_array['error'][$index]); // validate files (only if not logged in as admin) if (!File::$apply_restrictions_to_admin && Permission::check('ADMIN')) { $valid = true; } else { // Set up the validator instance with rules $validator = new Upload_Validator(); if (!$allowed_extensions) { $allowed_extensions = File::$allowed_extensions; } $validator->setAllowedExtensions($allowed_extensions); $validator->setAllowedMaxFileSize(self::$allowed_max_file_size); // Do the upload validation with the rules $upload = new Upload(); $upload->setValidator($validator); $valid = $upload->validate($tmpFile); if (!$valid) { $errors = $upload->getErrors(); if ($errors) { foreach ($errors as $error) { $errorResponse .= $error; } } } } // move file to given folder if ($valid) { $newFile = $folder->addUploadToFolder($tmpFile); $newFiles[] = $newFile; } else { return $errorResponse; } foreach ($newFiles as $newFile) { $fileIDs[] = $newFile; $fileObj = DataObject::get_one('File', "\"File\".\"ID\"={$newFile}"); if (method_exists($fileObj, 'onAfterUpload')) { $fileObj->onAfterUpload(); } } } } } else { return "File is too large."; } return $newFiles; }
function getPhoto() { $pic = new Upload($this->photo_id); if ($pic->exists()) { return $pic->url; } else { return '/assets/images/default.jpg'; } }
public function upload() { if ($_SESSION['iuser']['id']) { if ($_POST['act'] == 'step1') { $model = new Upload(); $model->step1(); $this->redirect('/fotobook/upload/step2/'); } elseif ($_POST['act'] == 'step2') { $model = new Upload(); $model->step2(); $this->redirect('/fotobook/upload/step3/'); } elseif ($_POST['act'] == 'step3') { $model = new Upload(); $model->step3(); View::$layout = 'empty'; View::render('fotobook/upload/step3done'); } elseif ($_POST['act'] == 'step3return') { $model = new Upload(); $model->step3return(); //$this->redirect('/fotobook/upload/step4/'); } elseif ($_POST['act'] == 'step4') { $model = new Upload(); $data = $model->step4(); $this->redirect('/fotobook/upload/thanks/', $data); } elseif (Funcs::$uri[2] == '') { $this->redirect('/fotobook/upload/step1/'); } elseif (Funcs::$uri[2] == 'step1') { $tree = Tree::getTreeByUrl('wide'); Funcs::setMeta($tree); View::render('fotobook/upload/step1', $tree); } elseif (Funcs::$uri[2] == 'step2') { $tree = Tree::getTreeByUrl('wide'); Funcs::setMeta($tree); View::render('fotobook/upload/step2', $tree); } elseif (Funcs::$uri[2] == 'step3') { $tree = Tree::getTreeByUrl('wide'); Funcs::setMeta($tree); View::render('fotobook/upload/step3', $tree); } elseif (Funcs::$uri[2] == 'step3show') { View::$layout = 'empty'; View::render('fotobook/upload/step3show'); } elseif (Funcs::$uri[2] == 'step4') { $tree = Tree::getTreeByUrl('wide'); Funcs::setMeta($tree); View::render('fotobook/upload/step4', $tree); } elseif (Funcs::$uri[2] == 'thanks') { $tree = Tree::getTreeByUrl('wide'); Funcs::setMeta($tree); View::render('fotobook/upload/thanks', $tree); } } else { $tree = Tree::getTreeByUrl('wide'); Funcs::setMeta($tree); View::render('fotobook/upload/page', $tree); } }
/** * 系统函数 * @access public */ function beforeAction() { $m = new Rotation(); $type = $m->gettype(); //$language = $m->getLanguageList(); $this->assign('type', $type); //$this->assign('language', $language); $upload = new Upload(); $this->assign('upload', $upload->show()); }
function salvar_foto() { include "upload.class.php"; echo "entrou no metodo"; if (isset($_POST["submit"]) && !empty($_FILES['foto'])) { $upload = new Upload($_FILES['foto'], 1000, 800, "../img/perfil/"); $upload->salvar(); } Header("Location: ../area_do_cliente.php?nav=perfil"); }
/** * Saves the uploaded file and returns the file info. * * @return stdClass * @throws Exception */ public function uploadFile() { try { $uploadManager = new Upload(); $uploadedFiles = $uploadManager->uploadFiles($_FILES); } catch (Exception $e) { // Log::doLog( $e->getMessage() ); throw new Exception($e->getMessage(), -8); } return $this->file = $uploadedFiles; }
public static function upload($index, $destination, $name, $pictureFormats) { $upload = new Upload(); $upload->set_file($_FILES[$index]); $upload->set_name($name); $upload->set_directory($destination); $param = array('type' => 'return'); $return = UploadManager::upload($upload, $pictureFormats, $param); $json = json_decode($return, true); return $json['status'] == 'success'; }