本文整理汇总了PHP中FileUpload类的典型用法代码示例。如果您正苦于以下问题:PHP FileUpload类的具体用法?PHP FileUpload怎么用?PHP FileUpload使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FileUpload类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: editorupload
public function editorupload()
{
$CRUD_AUTH = $this->session->userdata('CRUD_AUTH');
if (empty($CRUD_AUTH)) {
exit;
}
if (isset($_GET['CKEditorFuncNum'])) {
require FCPATH . '/application/third_party/scrud/class/FileUpload.php';
$msg = '';
// Will be returned empty if no problems
$callback = $_GET['CKEditorFuncNum'];
// Tells CKeditor which function you are executing
$fileUpload = new FileUpload();
$fileUpload->uploadDir = __IMAGE_UPLOAD_REAL_PATH__;
$fileUpload->extensions = array('.bmp', '.jpeg', '.jpg', '.png', '.gif');
$fileUpload->tmpFileName = $_FILES['upload']['tmp_name'];
$fileUpload->fileName = $_FILES['upload']['name'];
$fileUpload->httpError = $_FILES['upload']['error'];
if ($fileUpload->upload()) {
$image_url = __MEDIA_PATH__ . "images/" . $fileUpload->newFileName;
}
$error = $fileUpload->getMessage();
if (!empty($error)) {
$msg = 'error : ' . implode("\n", $error);
}
$output = '<script type="text/javascript">window.parent.CKEDITOR.tools.callFunction(' . $callback . ', "' . $image_url . '","' . $msg . '");</script>';
echo $output;
}
}
开发者ID:Dannyngs,项目名称:kim_hung_aquarium,代码行数:29,代码来源:scrud.php
示例2: upload
function upload()
{
$path = "./uploads/";
//设置图片上传路径
$up = new FileUpload($path);
//创建文件上传类对象
if ($up->upload('pic')) {
//上传图片
$filename = $up->getFileName();
//获取上传后的图片名
$img = new Image($path);
//创建图像处理类对象
$img->thumb($filename, 300, 300, "");
//将上传的图片都缩放至在300X300以内
$img->thumb($filename, 80, 80, "icon_");
//缩放一个80x80的图标,使用icon_作前缀
$img->watermark($filename, "logo.gif", 5, "");
//为上传的图片加上图片水印
return array(true, $filename);
//如果成功返回成功状态和图片名称
} else {
return array(false, $up->getErrorMsg());
//如果失败返回失败状态和错误消息
}
}
开发者ID:EmbededC,项目名称:Community-resource-management,代码行数:25,代码来源:func.inc.php
示例3: actionUpdate
public function actionUpdate($id)
{
$model = ARGroupon::model()->findByPk($id);
if ($model == null) {
$this->go('该商品不存在', Yii::app()->request->urlReferrer);
}
$model->setScenario('sell');
$this->performAjaxValidation($model);
if (!empty($_POST['ARGroupon'])) {
// dump($_FILES);
// dump($_POST);exit;
$model->attributes = $_POST['ARGroupon'];
if ($model->validate()) {
$fileUpload = new FileUpload(array($model, 'image'), 'upload/groupon');
if (!$fileUpload->isNull()) {
$filename = $fileUpload->save();
if ($filename) {
$model->image = $filename;
} else {
dump($fileUpload->getErrors());
throw new CHttpException(300, '图片上传出错');
}
}
$model->begin_time = strtotime($model->begin_time);
$model->end_time = strtotime($model->end_time);
$model->expire_time = strtotime($model->expire_time);
if ($model->save()) {
Yii::app()->user->setFlash('success', '商品修改成功');
// $url = $_POST['return_url'];
// $this->go('商品修改成功', $url, 'success');
}
}
}
$this->render('update', array('model' => $model));
}
开发者ID:jackycgq,项目名称:advanced,代码行数:35,代码来源:GrouponController.php
示例4: m_updateCompInfo
function m_updateCompInfo()
{
if (!isset($this->request['bill_state_id']) || empty($this->request['bill_state_id'])) {
$this->request['bill_state_id'] = "";
} else {
$this->request['bill_state'] = "";
}
#FILE UPLOADING START
if ($this->libFunc->checkImageUpload("image1") && $_FILES["image1"]["tmp_name"] != "") {
$fileUpload = new FileUpload();
$fileUpload->source = $_FILES["image1"]["tmp_name"];
$fileUpload->target = $this->imagePath . "company/" . $_FILES["image1"]["name"];
$newName1 = $fileUpload->upload();
$fileUpload->resampleImage($this->imagePath . "company/" . $newName1, 250, 250, 100);
// [/DRK]
if ($newName1 != false) {
$image1 = $newName1;
}
} else {
$this->obDb->query = "SELECT vLogo FROM " . COMPANYSETTINGS;
$logo = $this->obDb->fetchQuery();
$image1 = $logo[0]->vLogo;
}
#INSERTING COMPANY DETAILS
$this->obDb->query = "UPDATE " . COMPANYSETTINGS . " SET \n\t\tvCname ='" . $this->libFunc->m_addToDB($this->request['storeName']) . "',\n\t\tvAddress ='" . $this->libFunc->m_addToDB($this->request['storeAddress']) . "',\n\t\tvCity ='" . $this->libFunc->m_addToDB($this->request['storeCity']) . "',\n\t\tvState='" . $this->libFunc->m_addToDB($this->request['bill_state_id']) . "',\n\t\tvStateName='" . $this->libFunc->m_addToDB($this->request['bill_state']) . "',\n\t\tvCountry='" . $this->libFunc->m_addToDB($this->request['bill_country_id']) . "',\n\t\tvZip='" . $this->libFunc->m_addToDB($this->request['storeZip']) . "',\n\t\tvFax ='" . $this->libFunc->m_addToDB($this->request['storeFax']) . "',\n\t\tvPhone ='" . $this->libFunc->m_addToDB($this->request['storePhone']) . "',\n\t\tvFreePhone ='" . $this->libFunc->m_addToDB($this->request['storeTollFree']) . "',\n\t\tvVatNumber ='" . $this->libFunc->m_addToDB($this->request['vatNumber']) . "',\n\t\tvRNumber ='" . $this->libFunc->m_addToDB($this->request['companyNumber']) . "',\n\t\tvSlogan ='" . $this->libFunc->m_addToDB($this->request['companySlogan']) . "',\n\t\tvLogo ='" . $image1 . "'";
$this->obDb->updateQuery();
$this->libFunc->m_mosRedirect(SITE_URL . "admin/adminindex.php?action=settings.company&msg=1");
}
开发者ID:penkoh,项目名称:TradingEye-V7.1.1,代码行数:28,代码来源:settings_db.php
示例5: actionUpdate
public function actionUpdate($id)
{
$model = $this->loadBiz(trim($id));
$model->setScenario('sell');
$this->performAjaxValidation($model);
if (!empty($_POST)) {
$model->attributes = $_POST['ARBiz'];
// dump($_FILES);
// 控制器中使用实例如下:
$upload = new FileUpload(array($model, 'license_photo'), 'upload/groupon');
//model处理文件上传 $upload = new FileUpload(array($model,'pic'),'upload/goods');
if (!$upload->isNull()) {
if ($filename = $upload->save()) {
$model->license_photo = $filename;
// dump($filename);
} else {
print_r($upload->getErrors());
throw new CHttpException('300', '文件上传失败');
}
}
// dump($model->attributes);
if ($model->save()) {
// $return_url = $_POST['return_url'];
$this->redirect(array('index'));
}
}
$this->render('update', array('model' => $model));
}
开发者ID:yinhe,项目名称:yincart,代码行数:28,代码来源:BizController.php
示例6: preform
public function preform()
{
$uploadFile = new FileUpload();
$uploadFile->set("path", "./images/");
$uploadFile->set("maxsize", 2000000);
$uploadFile->set("allowtype", array("gif", "png", "jpg", "jpeg"));
$uploadFile->set("israndname", false);
}
开发者ID:sujinw,项目名称:webPHP,代码行数:8,代码来源:AddArticleModel.class.php
示例7: _performUploadTemplate
/**
* installs an uploaded template
*/
function _performUploadTemplate()
{
// handle the uploaded file
$files = HttpVars::getFiles();
$uploads = new FileUploads($files);
if (count($files) == 0 || $files["templateFile"]["name"] == "") {
$this->_view = new AdminTemplatedView($this->_blogInfo, "newglobaltemplate");
$this->_view->setValue("templateFolder", TemplateSetStorage::getBaseTemplateFolder());
$this->_view->setErrorMessage($this->_locale->tr("error_must_upload_file"));
$this->setCommonData();
return false;
}
$config =& Config::getConfig();
$tmpFolder = $config->getValue('temp_folder');
// move it to the temporary folder
$result = $uploads->process($tmpFolder);
// and from there, unpack it
$upload = new FileUpload($files['templateFile']);
$templateSandbox = new TemplateSandbox();
$valid = $templateSandbox->checkTemplateSet($upload->getFileName(), $tmpFolder . '/');
if ($valid < 0) {
$this->_view = new AdminSiteTemplatesListView($this->_blogInfo);
$this->_view->setErrorMessage($this->_checkTemplateSandboxResult($valid));
$this->setCommonData();
return false;
}
// the template was ok, so then we can proceed and move it to the main
// template folder, add it to our array of templates
//
// :KLUDGE:
//
// maybe we should simply move the files rather than unpacking the whole
// thing again, but this indeed makes things easier! ;)
$unpacker = new Unpacker();
$templateFolder = $config->getValue('template_folder');
$fileToUnpack = $tmpFolder . '/' . $upload->getFileName();
if (!$unpacker->unpack($fileToUnpack, $templateFolder)) {
$this->_view = new AdminSiteTemplatesListView($this->_blogInfo);
$tf = new Textfilter();
$this->_view->setErrorMessage($this->_locale->pr('error_installing_template', $tf->filterAllHtml($upload->getFileName())));
$this->setCommonData();
return false;
}
// if the template set was installed ok in the template folder, we can record
// it as a valid set
$ts = new TemplateSetStorage();
$fileParts = explode(".", $upload->getFileName());
$templateName = $fileParts[0];
$ts->addTemplate($templateName);
$this->_view = new AdminSiteTemplatesListView($this->_blogInfo);
$this->_view->setSuccessMessage($this->_locale->pr('template_installed_ok', $templateName));
$this->setCommonData();
return true;
}
开发者ID:BackupTheBerlios,项目名称:plogfr-svn,代码行数:57,代码来源:adminaddtemplateaction.class.php
示例8: image
/**
* 处理上传图片,重命名放到指定目录下,这里这个函数用来上传用户头像
* */
public function image()
{
//上传控件的名称是upload
$fileUpload = new FileUpload('upload', $_POST['MAX_FILE_SIZE']);
$ckefn = $_GET['CKEditorFuncNum'];
$path = $fileUpload->getPath();
$img = new Image($path);
$img->ckeImg(650, 0);
$img->out();
echo "<script>window.parent.CKEDITOR.tools.callFunction({$ckefn},\"{$path}\", '图片上传成功')</script>";
}
开发者ID:denglitong,项目名称:mvc,代码行数:14,代码来源:UploadController.class.php
示例9: edit
public function edit($data)
{
if (isset($data['artist_image'])) {
$imgUploader = new FileUpload($data['artist_image']['name'], $data['artist_image']['tmp_name']);
$l_sNewFileName = $imgUploader->image(ROOT . '/public/assets/artist/');
$imgUploader->image(ROOT . '/public/assets/artist/thumb/', 275, 322, $data['cropped'][0], $data['cropped'][1], $data['cropped'][2], $data['cropped'][3]);
$this->db->update('artist', array('artist_name' => $data['artist_name'], 'artist_active' => $data['artist_active'], 'artist_website' => $data['artist_website'], 'artist_featured' => $data['artist_featured'], 'artist_country' => $data['artist_country'], 'artist_description' => $data['artist_description'], 'artist_image' => $l_sNewFileName), "artist_id = {$data['artist_id']}");
} else {
$this->db->update('artist', array('artist_name' => $data['artist_name'], 'artist_active' => $data['artist_active'], 'artist_website' => $data['artist_website'], 'artist_featured' => $data['artist_featured'], 'artist_country' => $data['artist_country'], 'artist_description' => $data['artist_description']), "artist_id = {$data['artist_id']}");
}
}
开发者ID:euBatham,项目名称:artaddict_2015,代码行数:11,代码来源:admin_artist_model.php
示例10: editSave
public function editSave($data)
{
if (isset($data['article_img'])) {
$imgUploader = new FileUpload($data['article_img']['name'], $data['article_img']['tmp_name']);
$l_sNewFileName = $imgUploader->image(ROOT . '/public/assets/product/');
$imgUploader->image(ROOT . '/public/assets/product/thumb/', 218, 129, $data['cropped'][0], $data['cropped'][1], $data['cropped'][2], $data['cropped'][3]);
$this->db->update('article', array('article_name' => $data['article_name'], 'article_price' => $data['article_price'], 'article_date' => $data['article_date'], 'category_id' => $data['category_id'], 'article_featured' => $data['article_featured'], 'artist_id' => $data['artist_id'], 'article_description' => $data['article_description'], 'article_img' => $l_sNewFileName), "article_id = {$data['article_id']}");
} else {
$this->db->update('article', array('article_name' => $data['article_name'], 'article_price' => $data['article_price'], 'article_date' => $data['article_date'], 'category_id' => $data['category_id'], 'article_featured' => $data['article_featured'], 'artist_id' => $data['artist_id'], 'article_description' => $data['article_description']), "article_id = {$data['article_id']}");
}
}
开发者ID:euBatham,项目名称:artaddict_2015,代码行数:11,代码来源:admin_article_model.php
示例11: editCuadro
private static function editCuadro($gestor, $sesion)
{
$obra = new Obra();
$obra->read();
$pkID = Request::post("pkID");
$nombre = Request::post("nombre");
$email = Request::post('email');
$usuario = $sesion->getUser();
$obra->setId_usuario($usuario);
/*Subir fotografia*/
$subir = new FileUpload("nuevaImagen");
$subir->setDestino("../../controlUsuario/cuadros/{$usuario}/");
$subir->setTamaño(100000000);
$subir->setNombre($nombre);
$subir->setPolitica(FileUpload::REEMPLAZAR);
if ($subir->upload()) {
echo 'Archivo subido con éxito';
$obra->setImagen($nombre . "." . $subir->getExtension());
} else {
echo 'Archivo no subido';
}
$obra->setImagen($nombre . "." . $subir->getExtension());
$r = $gestor->set($obra, $pkID);
echo $r;
//header("Location:index.php?op=edit&r=$r");
}
开发者ID:jjorgosogarcia,项目名称:PhpGaleria,代码行数:26,代码来源:ControladorObra.php
示例12: uploadAction
/**
* Uploaded files are POSTed here
*/
public function uploadAction()
{
require_once 'models/table/File.php';
$return = array();
if (isset($_FILES['upload'])) {
if (!$_FILES['upload']['error']) {
// Check for upload directory
$uploadDir = $this->getUploadDir();
$name = $this->checkFile($_FILES['upload']['name']);
move_uploaded_file($_FILES['upload']['tmp_name'], "{$uploadDir}/{$name}");
$data['parent_id'] = $_POST['parent_id'];
$data['parent_table'] = $_POST['parent_table'];
$data['filemime'] = $_FILES['upload']['type'];
$data['filesize'] = $_FILES['upload']['size'];
$data['filename'] = $name;
$fileTable = new File();
$data['id'] = $fileTable->insert($data);
$data['creator_name'] = $this->view->identity->first_name . ' ' . $this->view->identity->last_name;
$dataArray = FileUpload::modifyRows(array($data));
$return = $dataArray[0];
// Strange JSON decoding error when sending hyperlink
$return['filename'] = strip_tags($return['filename']);
} else {
$return['error'] = 'Error uploading file. id: ' . $_FILES['upload']['error'];
}
}
require_once 'Zend/Json.php';
echo Zend_Json::encode($return);
exit;
}
开发者ID:falafflepotatoe,项目名称:trainsmart-code,代码行数:33,代码来源:FileController.php
示例13: indexAction
public function indexAction()
{
$this->_redirect('employee/search');
exit;
## old dash function
if (!$this->hasACL('edit_employee')) {
$this->doNoAccessError();
}
require_once 'models/table/dash-employee.php';
$this->view->assign('title', $this->translation['Application Name'] . space . t('Employee Tracking System'));
// restricted access?? does this user only have acl to view some trainings or people
// they dont want this, removing 5/01/13
## $org_allowed_ids = allowed_org_access_full_list($this); // doesnt have acl 'training_organizer_option_all'?
## $allowedWhereClause = $org_allowed_ids ? " partner.organizer_option_id in ($org_allowed_ids) " : "";
// restricted access?? only show organizers that belong to this site if its a multi org site
## $site_orgs = allowed_organizer_in_this_site($this); // for sites to host multiple training organizers on one domain
## $allowedWhereClause .= $site_orgs ? " AND partner.organizer_option_id in ($site_orgs) " : "";
$institute = new DashviewEmployee();
$details = $institute->fetchdetails($org_allowed_ids);
$this->view->assign('getins', $details);
/****************************************************************************************************************/
/* Attached Files */
require_once 'views/helpers/FileUpload.php';
$PARENT_COMPONENT = 'employee';
FileUpload::displayFiles($this, $PARENT_COMPONENT, 1, $this->hasACL('admin_files'));
// File upload form
if ($this->hasACL('admin_files')) {
$this->view->assign('filesForm', FileUpload::displayUploadForm($PARENT_COMPONENT, 1, FileUpload::$FILETYPES));
}
/****************************************************************************************************************/
}
开发者ID:falafflepotatoe,项目名称:trainsmart-code,代码行数:31,代码来源:EmployeeController.php
示例14: ckeUp
public function ckeUp()
{
if (isset($_GET['type'])) {
//查看了源代码,他的名称是:upload
$_fileupload = new FileUpload('upload', $_POST['MAX_FILE_SIZE']);
$_ckefn = $_GET['CKEditorFuncNum'];
$_path = $_fileupload->getPath();
$_img = new Image($_path);
$_img->ckeImg(650, 0);
$_img->out();
echo "<script type='text/javascript'>window.parent.CKEDITOR.tools.callFunction({$_ckefn},\".{$_path}\",'图片上传成功!');</script>";
exit;
} else {
Tool::alertBack('警告:由于非法操作导致上传失败!');
}
}
开发者ID:yjf0503,项目名称:Mall,代码行数:16,代码来源:CallAction.class.php
示例15: edit
public function edit($data)
{
$dataArray = array('event_name' => $data['event_name'], 'event_date' => $data['event_date'], 'event_date_end' => $data['event_date_end'], 'event_description' => $data['event_description']);
if (isset($data['event_image']) || isset($data['event_file'])) {
if (isset($data['event_image'])) {
$imgUploader = new FileUpload($data['event_image']['name'], $data['event_image']['tmp_name']);
$l_sNewFileName = $imgUploader->image(ROOT . '/public/assets/event/');
$imgUploader->image(ROOT . '/public/assets/event/thumb/', 275, 163, $data['cropped'][0], $data['cropped'][1], $data['cropped'][2], $data['cropped'][3]);
$dataArray['event_image'] = $l_sNewFileName;
}
if (isset($data['event_file'])) {
$fileUploader = new FileUpload($data['event_file']['name'], $data['event_file']['tmp_name']);
$l_sNewFileName = $fileUploader->file(ROOT . '/public/assets/file/');
$dataArray['event_file'] = $l_sNewFileName;
}
$this->db->update('event', $dataArray, "event_id = {$data['event_id']}");
} else {
$this->db->update('event', $dataArray, "event_id = {$data['event_id']}");
}
}
开发者ID:euBatham,项目名称:artaddict_2015,代码行数:20,代码来源:admin_event_model.php
示例16: testSingleUpload
public function testSingleUpload()
{
$playground_path = __DIR__ . '/../playground';
$server = array('CONTENT_TYPE' => 'image/jpg', 'CONTENT_LENGTH' => 30321);
$file = array('tmp_name' => $playground_path . '/real-image.jpg', 'name' => 'real-image.jpg', 'size' => 30321, 'type' => 'image/jpg', 'error' => 0);
$filesystem = new FileSystem\Mock();
$resolver = new PathResolver\Simple($playground_path . '/uploaded');
$uploader = new FileUpload($file, $server);
$test = false;
$uploader->setPathResolver($resolver);
$uploader->setFileSystem($filesystem);
$uploader->addCallback('completed', function () use(&$test) {
$test = true;
});
list($files, $headers) = $uploader->processAll();
$this->assertCount(1, $files, 'Files array should contain one file');
$this->assertEquals(0, $files[0]->error, 'Uploaded file should not have errors');
$this->assertNotEmpty($files[0]->path, 'Uploaded file should have path');
$this->assertTrue($test, 'Complete callback should set $test to true');
}
开发者ID:adelowo,项目名称:fileupload,代码行数:20,代码来源:FileUploadTest.php
示例17: validateUpload
/**
* Validate the upload
* @return string
*/
public function validateUpload()
{
\Message::reset();
$objUploader = new \FileUpload();
$objUploader->setName($this->strName);
$uploadFolder = $this->strTempFolder;
// Convert the $_FILES array to Contao format
if (!empty($_FILES[$this->strName])) {
$pathinfo = pathinfo(strtolower($_FILES[$this->strName]['name']));
$strCacheName = standardize($pathinfo['filename']) . '.' . $pathinfo['extension'];
$uploadFolder = $this->strTempFolder . '/' . substr($strCacheName, 0, 1);
if (is_file(TL_ROOT . '/' . $uploadFolder . '/' . $strCacheName) && md5_file(TL_ROOT . '/' . $uploadFolder . '/' . $_FILES[$this->strName]['name']) != md5_file(TL_ROOT . '/' . $uploadFolder . '/' . $strCacheName)) {
$strCacheName = standardize($pathinfo['filename']) . '-' . substr(md5_file(TL_ROOT . '/' . $uploadFolder . '/' . $_FILES[$this->strName]['name']), 0, 8) . '.' . $pathinfo['extension'];
$uploadFolder = $this->strTempFolder . '/' . substr($strCacheName, 0, 1);
}
\Haste\Haste::mkdirr($uploadFolder);
$arrFallback = $this->getFallbackData();
// Check that image is not assigned in fallback language
if (is_array($arrFallback) && in_array($strCacheName, $arrFallback)) {
$this->addError($GLOBALS['TL_LANG']['ERR']['imageInFallback']);
}
$_FILES[$this->strName] = array('name' => array($strCacheName), 'type' => array($_FILES[$this->strName]['type']), 'tmp_name' => array($_FILES[$this->strName]['tmp_name']), 'error' => array($_FILES[$this->strName]['error']), 'size' => array($_FILES[$this->strName]['size']));
}
$varInput = '';
try {
$varInput = $objUploader->uploadTo($uploadFolder);
} catch (\Exception $e) {
$this->addError($e->getMessage());
}
if ($objUploader->hasError()) {
foreach ($_SESSION['TL_ERROR'] as $strError) {
$this->addError($strError);
}
}
\Message::reset();
if (!is_array($varInput) || empty($varInput)) {
$this->addError($GLOBALS['TL_LANG']['MSC']['mmUnknownError']);
}
return $varInput[0];
}
开发者ID:Aziz-JH,项目名称:core,代码行数:44,代码来源:MediaManager.php
示例18: process
/**
* Goes through the array of files and processes them accordingly.
* The result is an array of the appropiate Resource class that has been
* created using the ResourceFactory class.
*
* @return An array of Upload objects that have already been moved to a safer
* location.
*/
function process($destinationFolder)
{
// first, check if the upload feature is available
$config =& Config::getConfig();
if (!$config->getValue("uploads_enabled")) {
return FILE_UPLOADS_NOT_ENABLED;
}
// array used to store the files that have already been saved
$uploads = array();
if ($destinationFolder[strlen($destinationFolder - 1)] != "/") {
$destinationFolder .= "/";
}
foreach ($this->_files as $file) {
$upload = new FileUpload($file);
$fileName = $upload->getFileName();
if ($this->my_move_uploaded_file($upload->getTmpName(), $destinationFolder . $fileName)) {
$upload->setFolder($destinationFolder);
$upload->setError(0);
} else {
$upload->setError(1);
}
array_push($uploads, $upload);
}
return $uploads;
}
开发者ID:BackupTheBerlios,项目名称:plogfr-svn,代码行数:33,代码来源:fileuploads.class.php
示例19: validateMimeType
/**
* MimeType validator: has file specified mime type?
* @param FileUpload
* @param array|string mime type
* @return bool
*/
public static function validateMimeType(FileUpload $control, $mimeType)
{
$file = $control->getValue();
if ($file instanceof HttpUploadedFile) {
$type = strtolower($file->getContentType());
$mimeTypes = is_array($mimeType) ? $mimeType : explode(',', $mimeType);
if (in_array($type, $mimeTypes, TRUE)) {
return TRUE;
}
if (in_array(preg_replace('#/.*#', '/*', $type), $mimeTypes, TRUE)) {
return TRUE;
}
}
return FALSE;
}
开发者ID:jaroslavlibal,项目名称:MDW,代码行数:21,代码来源:FileUpload.php
示例20: testCreateAndRetrieveCurlFile
public function testCreateAndRetrieveCurlFile()
{
if (!class_exists('\\CurlFile', false)) {
// Older PHP versions don't support this
return;
}
$curlFile = new \CurlFile(dirname(__FILE__) . '/../data/test.png');
self::authorizeFromEnv();
$file = FileUpload::create(array('purpose' => 'dispute_evidence', 'file' => $curlFile));
$this->assertSame(95, $file->size);
$this->assertSame('png', $file->type);
// Just check that we don't get exceptions
$file = FileUpload::retrieve($file->id);
$file->refresh();
}
开发者ID:BenComicGraphics,项目名称:stripe-php,代码行数:15,代码来源:FileUploadTest.php
注:本文中的FileUpload类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论