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


PHP FileUpload::setName方法代码示例

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


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

示例1: 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

示例2: ManageUser

$userManager = new ManageUser($db);
$sesion = new Session();
$email = Request::post("email");
$newemail = Request::post("newemail");
$pass = Request::post("pass");
$alive = Request::post("alive");
$worker = Request::post("worker");
$admin = Request::post("admin");
$newemail = $newemail === null ? $email : $newemail;
$alive = $alive === null ? 0 : 1;
$worker = $worker === null ? 0 : 1;
$admin = $admin === null ? 0 : 1;
$usuario = $userManager->get($email);
$usuario->setEmail($newemail);
$usuario->setAlias(explode("@", $newemail)[0]);
$usuario->setAlive($alive);
$usuario->setWorker($worker);
$usuario->setAdmin($admin);
if ($pass !== null) {
    $usuario->setPass($pass);
}
$photo = new FileUpload("image");
if ($photo->getError() === false) {
    $usuario->setImage("images/" . $usuario->getAlias() . ".jpg");
    $photo->setDestination("../images/");
    $photo->setName($usuario->getAlias());
    echo $photo->upload();
}
$userManager->setEmail($usuario, $email);
$sesion->destroy();
$sesion->sendRedirect("../admin.php");
开发者ID:davidgamarra,项目名称:DWESI_Practice4_UserManager,代码行数:31,代码来源:phpedituser.php

示例3: validateUpload

 /**
  * Validate the upload
  * @return string
  */
 public function validateUpload()
 {
     \Message::reset();
     $strTempName = $this->strName . '_upload';
     $objUploader = new \FileUpload();
     $objUploader->setName($this->strName);
     // Convert the $_FILES array to Contao format
     if (!empty($_FILES[$strTempName])) {
         $arrFile = array('name' => array($_FILES[$strTempName]['name']), 'type' => array($_FILES[$strTempName]['type']), 'tmp_name' => array($_FILES[$strTempName]['tmp_name']), 'error' => array($_FILES[$strTempName]['error']), 'size' => array($_FILES[$strTempName]['size']));
         // Check if the file exists
         if (file_exists(TL_ROOT . '/' . $this->strTemporaryPath . '/' . $arrFile['name'][0])) {
             $arrFile['name'][0] = $this->getFileName($arrFile['name'][0], $this->strTemporaryPath);
         }
         $_FILES[$this->strName] = $arrFile;
         unset($_FILES[$strTempName]);
         // Unset the temporary file
     }
     $varInput = '';
     $maxlength = null;
     // Override the default maxlength value
     if (isset($this->arrConfiguration['maxlength'])) {
         $maxlength = $GLOBALS['TL_CONFIG']['maxFileSize'];
         $GLOBALS['TL_CONFIG']['maxFileSize'] = $this->getMaximumFileSize();
     }
     try {
         $varInput = $objUploader->uploadTo($this->strTemporaryPath);
         if ($objUploader->hasError()) {
             foreach ($_SESSION['TL_ERROR'] as $strError) {
                 $this->addError($strError);
             }
         }
         \Message::reset();
     } catch (\Exception $e) {
         $this->addError($e->getMessage());
     }
     // Restore the default maxlength value
     if ($maxlength !== null) {
         $GLOBALS['TL_CONFIG']['maxFileSize'] = $maxlength;
     }
     if (!is_array($varInput) || empty($varInput)) {
         $this->addError($GLOBALS['TL_LANG']['MSC']['avatar_error']);
     }
     $varInput = $varInput[0];
     $strExtension = pathinfo($varInput, PATHINFO_EXTENSION);
     $arrAllowedTypes = trimsplit(',', strtolower($this->getAllowedExtensions()));
     // File type not allowed
     if (!in_array(strtolower($strExtension), $arrAllowedTypes)) {
         $this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['filetype'], $strExtension));
     }
     // Check image size
     if (($arrImageSize = @getimagesize(TL_ROOT . '/' . $varInput)) !== false) {
         // Image exceeds maximum image width
         if ($arrImageSize[0] > $GLOBALS['TL_CONFIG']['imageWidth']) {
             $this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['filewidth'], '', $GLOBALS['TL_CONFIG']['imageWidth']));
         }
         // Image exceeds maximum image height
         if ($arrImageSize[1] > $GLOBALS['TL_CONFIG']['imageHeight']) {
             $this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['fileheight'], '', $GLOBALS['TL_CONFIG']['imageHeight']));
         }
         // Image exceeds minimum image width
         if ($arrImageSize[0] < $this->arrAvatarSize[0]) {
             $this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['avatar_width'], $this->arrAvatarSize[0]));
         }
         // Image exceeds minimum image height
         if ($arrImageSize[1] < $this->arrAvatarSize[1]) {
             $this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['avatar_height'], $this->arrAvatarSize[1]));
         }
     }
     return $varInput;
 }
开发者ID:revision6,项目名称:contao-avatar,代码行数:74,代码来源:AvatarWidgetBase.php

示例4: validateUpload

 /**
  * Validate the upload
  * @return string
  */
 public function validateUpload()
 {
     \Message::reset();
     $strTempName = $this->strName . '_fineuploader';
     $objUploader = new \FileUpload();
     $objUploader->setName($this->strName);
     $blnIsChunk = isset($_POST['qqpartindex']);
     // Convert the $_FILES array to Contao format
     if (!empty($_FILES[$strTempName])) {
         $arrFile = array('name' => array($_FILES[$strTempName]['name']), 'type' => array($_FILES[$strTempName]['type']), 'tmp_name' => array($_FILES[$strTempName]['tmp_name']), 'error' => array($_FILES[$strTempName]['error']), 'size' => array($_FILES[$strTempName]['size']));
         // Set the UUID as the filename
         if ($blnIsChunk) {
             $arrFile['name'][0] = \Input::post('qquuid') . '.chunk';
         }
         // Check if the file exists
         if (file_exists(TL_ROOT . '/' . $this->strTemporaryPath . '/' . $arrFile['name'][0])) {
             $arrFile['name'][0] = $this->getFileName($arrFile['name'][0], $this->strTemporaryPath);
         }
         $_FILES[$this->strName] = $arrFile;
         unset($_FILES[$strTempName]);
         // Unset the temporary file
     }
     $varInput = '';
     $extensions = null;
     $maxlength = null;
     // Add the "chunk" extension to upload types
     if ($blnIsChunk) {
         $extensions = $GLOBALS['TL_CONFIG']['uploadTypes'];
         $GLOBALS['TL_CONFIG']['uploadTypes'] .= ',chunk';
     }
     // Override the default maxlength value
     if (isset($this->arrConfiguration['maxlength'])) {
         $maxlength = $GLOBALS['TL_CONFIG']['maxFileSize'];
         $GLOBALS['TL_CONFIG']['maxFileSize'] = $this->arrConfiguration['maxlength'];
     }
     try {
         $varInput = $objUploader->uploadTo($this->strTemporaryPath);
         if ($objUploader->hasError()) {
             foreach ($_SESSION['TL_ERROR'] as $strError) {
                 $this->addError($strError);
             }
         }
         \Message::reset();
     } catch (\Exception $e) {
         $this->addError($e->getMessage());
     }
     // Restore the default maxlength value
     if ($maxlength !== null) {
         $GLOBALS['TL_CONFIG']['maxFileSize'] = $maxlength;
     }
     // Restore the default extensions value
     if ($extensions !== null) {
         $GLOBALS['TL_CONFIG']['uploadTypes'] = $extensions;
     }
     if (!is_array($varInput) || empty($varInput)) {
         $this->addError($GLOBALS['TL_LANG']['MSC']['fineuploader_error']);
     }
     $varInput = $varInput[0];
     // Store the chunk in the session for further merge
     if ($blnIsChunk) {
         $_SESSION[$this->strName . '_FINEUPLOADER_CHUNKS'][\Input::post('qqfilename')][] = $varInput;
         // This is the last chunking request, merge the chunks and create the final file
         if (\Input::post('qqpartindex') == \Input::post('qqtotalparts') - 1) {
             $strFileName = \Input::post('qqfilename');
             // Get the new file name
             if (file_exists(TL_ROOT . '/' . $this->strTemporaryPath . '/' . $strFileName)) {
                 $strFileName = $this->getFileName($strFileName, $this->strTemporaryPath);
             }
             $objFile = new \File($this->strTemporaryPath . '/' . $strFileName);
             // Merge the chunks
             foreach ($_SESSION[$this->strName . '_FINEUPLOADER_CHUNKS'][\Input::post('qqfilename')] as $strChunk) {
                 $objFile->append(file_get_contents(TL_ROOT . '/' . $strChunk), '');
                 // Delete the file
                 \Files::getInstance()->delete($strChunk);
             }
             $objFile->close();
             $varInput = $objFile->path;
         }
     }
     return $varInput;
 }
开发者ID:kikmedia,项目名称:contao-fineuploader,代码行数:85,代码来源:FineUploaderBase.php

示例5: FileUpload

echo Filtrar::isInt($mes);
echo Filtrar::isInt($anio);
echo Filtrar::isInt($Tipo_Id);
if (Server::getRequestDate("Y") - $anio >= 14) {
    if ($dni == NULL || $dni == "") {
        echo "Documento de identidad obligatorio";
    }
}
if (strlen($id_us) <= 8) {
    echo "Nº de Tarjeta Sanitaria: incorrecto";
}
if ($dia < 1 || $dia > 31) {
    echo "Dias entre 1-31";
}
if ($mes < 1 || $mes > 12) {
    echo "Mes entre 1-12";
}
if (strlen($anio) < 4) {
    echo "Año debe tener 4 cifras";
}
if (strlen($dni) < 9) {
    echo "DNI debe tenr nueve caracteres";
}
$imagen = new FileUpload("archivo");
$imagen->setStore("img/");
$nombreOriginal = $imagen->getName();
$imagen->setName("_U_" . $usuario . "_X_" . $categoria . "_T_" . $privada . "_C_" . $nombreOriginal);
$imagen->getPolicy(FileUpload::RENAME);
$imagen->addType("gif");
$imagen->setSize(52428800);
var_dump($imagen);
开发者ID:ealvarez1990,项目名称:sas,代码行数:31,代码来源:sas_subir.php

示例6: fileupload

 /**
  * move uploaded file to the album directory
  *
  * @param $intAlbumId
  * @param string $strName
  * @return array
  */
 public static function fileupload($intAlbumId, $strName = 'file')
 {
     $blnIsError = false;
     // Get the album object
     $objAlb = \GalleryCreatorAlbumsModel::findById($intAlbumId);
     if ($objAlb === null) {
         $blnIsError = true;
         \Message::addError('Album with ID ' . $intAlbumId . ' does not exist.');
     }
     // Check for a valid upload directory
     $objUploadDir = \FilesModel::findByUuid($objAlb->assignedDir);
     if ($objUploadDir === null || !is_dir(TL_ROOT . '/' . $objUploadDir->path)) {
         $blnIsError = true;
         \Message::addError('No upload directory defined in the album settings!');
     }
     // Check if there are some files in $_FILES
     if (!is_array($_FILES[$strName])) {
         $blnIsError = true;
         \Message::addError('No Files selected for the uploader.');
     }
     if ($blnIsError) {
         return array();
     }
     // Adapt $_FILES if files are loaded up by jumploader (java applet)
     if (!is_array($_FILES[$strName]['name'])) {
         $arrFile = array('name' => $_FILES[$strName]['name'], 'type' => $_FILES[$strName]['type'], 'tmp_name' => $_FILES[$strName]['tmp_name'], 'error' => $_FILES[$strName]['error'], 'size' => $_FILES[$strName]['size']);
         unset($_FILES);
         //rebuild $_FILES for the Contao FileUpload class
         $_FILES[$strName]['name'][0] = $arrFile['name'];
         $_FILES[$strName]['type'][0] = $arrFile['type'];
         $_FILES[$strName]['tmp_name'][0] = $arrFile['tmp_name'];
         $_FILES[$strName]['error'][0] = $arrFile['error'];
         $_FILES[$strName]['size'][0] = $arrFile['size'];
     }
     // Do not overwrite files of the same filename
     $intCount = count($_FILES[$strName]['name']);
     for ($i = 0; $i < $intCount; $i++) {
         if (strlen($_FILES[$strName]['name'][$i])) {
             // Generate unique filename
             $_FILES[$strName]['name'][$i] = basename(self::generateUniqueFilename($objUploadDir->path . '/' . $_FILES[$strName]['name'][$i]));
         }
     }
     // Resize image if feature is enabled
     if (\Input::post('img_resolution') > 1) {
         \Config::set('imageWidth', \Input::post('img_resolution'));
         \Config::set('jpgQuality', \Input::post('img_quality'));
     } else {
         \Config::set('maxImageWidth', 999999999);
     }
     // Call the Contao FileUpload class
     $objUpload = new \FileUpload();
     $objUpload->setName($strName);
     $arrUpload = $objUpload->uploadTo($objUploadDir->path);
     foreach ($arrUpload as $strFileSrc) {
         // Store file in tl_files
         \Dbafs::addResource($strFileSrc);
     }
     return $arrUpload;
 }
开发者ID:Aiod,项目名称:gallery_creator,代码行数:66,代码来源:GcHelpers.php

示例7: __construct

 /**
  * Initialize the FileUpload object
  * @param array
  */
 public function __construct($arrAttributes = null)
 {
     parent::__construct($arrAttributes);
     $this->objUploader = new \FileUpload();
     $this->objUploader->setName($this->strName);
 }
开发者ID:rburch,项目名称:core,代码行数:10,代码来源:Upload.php

示例8: saveFile

 /**
  * Will save the image file as it is [If we only need to upload image without creating the thumbnails]
  *
  * @param file $file_element
  * @param string $module_name
  * @param integer $record_id
  * @param string $file_upload_path
  * @param string $filename
  */
 public function saveFile($file_element, $module_name = "", $record_id, $file_upload_path, $is_main_resize = false, $is_thumbnail = false)
 {
     $fileObj = new FileUpload();
     $fileObj->doInitialize($file_element);
     $filename = substr($file_element['name'], 0, strrpos($file_element['name'], '.'));
     $filename = $module_name . "_" . $record_id . $fileObj->getExtension();
     $fileObj->setName($filename);
     $fileObj->saveAs($file_upload_path);
     //to save the file physically on given location
     $savedImgPath = $fileObj->getFullPath();
     //This holds the full path of the file
     if ($is_main_resize) {
         $mainResize = PhpThumbFactory::create($savedImgPath);
         $mainResize->resize($this->mWidth, $this->mHeight);
         $mainResize->save($file_upload_path . $fileObj->getName());
     }
     if ($is_thumbnail) {
         $thumb = PhpThumbFactory::create($savedImgPath);
         //$thumb->adaptiveResize(80, 80);
         $thumb->resize($this->mThumbWidth, $this->mThumbHeight);
         $thumb->save($file_upload_path . "thumbnail/" . $fileObj->getName());
     }
     return $filename;
 }
开发者ID:PropertBlast,项目名称:property_blast,代码行数:33,代码来源:ImageUpload.php

示例9: insertArt

 private static function insertArt()
 {
     $sesion = new Session();
     if ($sesion->isLogged()) {
         $db = new DataBase();
         $manager = new ManageArt($db);
         $managerUser = new ManageUser($db);
         $email = Request::post("email");
         $title = Request::post("title");
         $usuario = $managerUser->get($email);
         $art = new Art();
         $art->setEmail($email);
         $art->setTitle($title);
         $art->setCdate(date('Y-m-d G:i:s'));
         $fecha = date('_Y_m_d_G_i_s');
         $photo = new FileUpload("image");
         if ($photo->getError() === false) {
             $art->setImage("./resources/art/" . $usuario->getAlias() . $fecha . ".jpg");
             $photo->setDestination("./resources/art/");
             $photo->setName($usuario->getAlias() . $fecha);
             $photo->upload();
         }
         $manager->insert($art);
         $db->close();
     }
     self::viewProfile();
 }
开发者ID:davidgamarra,项目名称:DWESI_Practice5_ArtGallery,代码行数:27,代码来源:Controller.php


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