本文整理汇总了PHP中util::uploadStatus方法的典型用法代码示例。如果您正苦于以下问题:PHP util::uploadStatus方法的具体用法?PHP util::uploadStatus怎么用?PHP util::uploadStatus使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类util
的用法示例。
在下文中一共展示了util::uploadStatus方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getSingleUploadedFile
/**
* Réalise l'upload d'une simple image et retourne son chemin.
*
* Par exemple utilisé pour l'upload des filigrane.
*
* Il n'y a PAS de création de miniature.
*
* @param $form_input_name Le nom du champs du formulaire
* @param $sCurrentImageDir Le chemin du répertoire destination
* @param $sFilename Le nom du fichier destination sans l'extension
* @return string Le nom de l'image
*/
public static function getSingleUploadedFile($form_input_name = 'p_file', $sCurrentImageDir, $sFilename)
{
global $okt;
$return = '';
if (isset($_FILES[$form_input_name]) && !empty($_FILES[$form_input_name]['tmp_name'])) {
$sUploadedFile = $_FILES[$form_input_name];
try {
# extension du fichier
$sExtension = pathinfo($sUploadedFile['name'], PATHINFO_EXTENSION);
# des erreurs d'upload ?
util::uploadStatus($sUploadedFile);
# vérification de l'extension
self::checkExtension($sExtension);
# vérification du type
self::checkType($sUploadedFile['type']);
# création du répertoire s'il existe pas
if (!file_exists($sCurrentImageDir)) {
files::makeDir($sCurrentImageDir, true);
}
# nom du fichier
$sOutput = $sFilename . '.' . $sExtension;
# suppression de l'éventuel ancien fichier
if (file_exists($sCurrentImageDir . $sOutput) && files::isDeletable($sCurrentImageDir . $sOutput)) {
unlink($sCurrentImageDir . $sOutput);
}
if (!move_uploaded_file($sUploadedFile['tmp_name'], $sCurrentImageDir . $sOutput)) {
throw new Exception('Impossible de déplacer sur le serveur le fichier téléchargé.');
}
$return = $sOutput;
} catch (Exception $e) {
$okt->error->set('Problème avec l’image : ' . $e->getMessage());
}
}
return $return;
}
示例2: array
$core_media_writable = $okt->media->writable();
# Prepare directories combo box
$dirs_combo = array();
foreach ($okt->media->getRootDirs() as $v) {
if ($v->w) {
$dirs_combo['/' . $v->relname] = $v->relname;
}
}
ksort($dirs_combo);
} catch (Exception $e) {
$okt->error->set($e->getMessage());
}
# Upload a new file
if ($file && !empty($_FILES['upfile']) && $file->editable && $core_media_writable) {
try {
util::uploadStatus($_FILES['upfile']);
$okt->media->uploadFile($_FILES['upfile']['tmp_name'], $file->basename, null, false, true);
$okt->page->flashMessages->addSuccess(__('File has been successfully updated.'));
http::redirect($page_url . '&id=' . $id);
} catch (Exception $e) {
$okt->error->set($e->getMessage());
}
}
# Update file
if ($file && !empty($_POST['media_file']) && $file->editable && $core_media_writable) {
$newFile = clone $file;
$newFile->basename = $_POST['media_file'];
if ($_POST['media_path']) {
$newFile->dir = $_POST['media_path'];
$newFile->relname = $_POST['media_path'] . '/' . $newFile->basename;
} else {
示例3: Exception
try {
if (!$iGalleryId) {
throw new Exception(__('m_galleries_zip_error_must_gallery_id'));
}
$rsGalleryLocales = $okt->galleries->tree->getGalleryI18n($iGalleryId);
foreach ($okt->languages->list as $aLanguage) {
while ($rsGalleryLocales->fetch()) {
if ($rsGalleryLocales->language == $aLanguage['code']) {
$aItemLocalesData[$aLanguage['code']]['title'] = $rsGalleryLocales->title;
}
}
if (!empty($_POST['p_title'][$aLanguage['code']])) {
$aItemLocalesData[$aLanguage['code']]['title'] = $_POST['p_title'][$aLanguage['code']];
}
}
util::uploadStatus($_FILES['p_zip_file']);
if (empty($_FILES['p_zip_file']) || empty($_FILES['p_zip_file']['tmp_name'])) {
throw new Exception(__('m_galleries_zip_error_must_zip_file') . ' (no file)');
}
if (pathinfo($_FILES['p_zip_file']['name'], PATHINFO_EXTENSION) != 'zip') {
throw new Exception(__('m_galleries_zip_error_must_zip_file') . ' (not zip extension)');
}
// if ($_FILES['p_zip_file']['type'] != 'application/zip' && $_FILES['p_zip_file']['type'] != 'application/x-zip-compressed') {
// if (strpos($_FILES['p_zip_file']['type'], 'zip') === false) {
// throw new Exception(__('m_galleries_zip_error_must_zip_file').' (not zip type : '.$_FILES['p_zip_file']['type'].')');
// }
$sTempDir = $okt->galleries->upload_dir . '/temp/';
files::makeDir($sTempDir, true);
$sZipFile = $sTempDir . $_FILES['p_zip_file']['name'];
if (!move_uploaded_file($_FILES['p_zip_file']['tmp_name'], $sZipFile)) {
throw new Exception(__('m_galleries_zip_error_unable_move_uploaded_file'));
示例4: array
$aThemesRepositories = array();
if ($okt->config->themes_repositories_enabled) {
$aRepositories = $okt->config->themes_repositories;
$aThemesRepositories = $oThemes->getRepositoriesInfos($aRepositories);
}
# Tri par ordre alphabétique des listes de thèmes des dépots
foreach ($aThemesRepositories as $repo_name => $themes) {
uasort($aThemesRepositories[$repo_name], array('oktThemes', 'sortThemesList'));
}
/* Traitements
----------------------------------------------------------*/
# Theme upload
if (!empty($_POST['upload_pkg']) && !empty($_FILES['pkg_file']) || !empty($_POST['fetch_pkg']) && !empty($_POST['pkg_url']) || !empty($_GET['repository']) && !empty($_GET['theme']) && $okt->config->themes_repositories_enabled) {
try {
if (!empty($_POST['upload_pkg'])) {
util::uploadStatus($_FILES['pkg_file']);
$dest = OKT_THEMES_PATH . '/' . $_FILES['pkg_file']['name'];
if (!move_uploaded_file($_FILES['pkg_file']['tmp_name'], $dest)) {
throw new Exception(__('Unable to move uploaded file.'));
}
} else {
if (!empty($_GET['repository']) && !empty($_GET['theme'])) {
$repository = urldecode($_GET['repository']);
$theme = urldecode($_GET['theme']);
$url = urldecode($aThemesRepositories[$repository][$theme]['href']);
} else {
$url = urldecode($_POST['pkg_url']);
}
$dest = OKT_THEMES_PATH . '/' . basename($url);
try {
$client = netHttp::initClient($url, $path);
示例5: pathinfo
/* Traitements
----------------------------------------------------------*/
if (!empty($_POST['form_sent'])) {
# traitement d'un éventuel theme uploadé
if (isset($_FILES['p_upload_theme']) && !empty($_FILES['p_upload_theme']['tmp_name'])) {
$sUploadedFile = $_FILES['p_upload_theme'];
$sTempDir = OKT_ROOT_PATH . '/temp/';
$sZipFilename = $sTempDir . $sUploadedFile['name'];
try {
# on supprime l'éventuel répertoire temporaire s'il existe déjà
if (is_dir($sTempDir)) {
files::deltree($sTempDir);
}
$sExtension = pathinfo($sUploadedFile['name'], PATHINFO_EXTENSION);
# des erreurs d'upload ?
util::uploadStatus($sUploadedFile);
# vérification de l'extension
if ($sExtension != 'zip') {
throw new Exception(__('c_a_config_display_not_zip_file'));
}
# création répertoire temporaire
files::makeDir($sTempDir);
if (!move_uploaded_file($sUploadedFile['tmp_name'], $sZipFilename)) {
throw new Exception(__('c_a_config_display_unable_move_file'));
}
$oZip = new fileUnzip($sZipFilename);
$oZip->getList(false, '#(^|/)(__MACOSX|\\.svn|\\.DS_Store|Thumbs\\.db|development-bundle|js)(/|$)#');
$zip_root_dir = $oZip->getRootDir();
if ($zip_root_dir !== false) {
$sTargetDir = dirname($sZipFilename);
$sDestinationDir = $sTargetDir . '/' . $zip_root_dir;
示例6: updFiles
/**
* Modification des fichiers
*
* @return array
*/
public function updFiles($iItemId, $aCurrentFiles = array())
{
$aNewFiles = array();
$j = 1;
for ($i = 1; $i <= $this->config['number']; $i++) {
if (!isset($_FILES[sprintf($this->config['files_patern'], $i)]) || empty($_FILES[sprintf($this->config['files_patern'], $i)]['tmp_name'])) {
if (isset($aCurrentFiles[$i])) {
$aNewFiles[$j] = array('filename' => $aCurrentFiles[$i]['filename'], 'title' => !empty($_REQUEST[sprintf($this->config['files_title_patern'], $i)]) ? $_REQUEST[sprintf($this->config['files_title_patern'], $i)] : $aCurrentFiles[$i]['title']);
$j++;
}
continue;
}
$sUploadedFile = $_FILES[sprintf($this->config['files_patern'], $i)];
try {
$sExtension = pathinfo($sUploadedFile['name'], PATHINFO_EXTENSION);
# des erreurs d'upload ?
util::uploadStatus($sUploadedFile);
# vérification de l'extension
$this->checkFile($sExtension);
# vérification du type
// $aAllowedTypes = array('image/jpeg', 'image/pjpeg', 'image/png', 'image/x-png');
// if (!in_array($sUploadedFile['type'], $aAllowedTypes)) {
// throw new Exception('Type de fichier non-autorisé.');
// }
# création du répertoire s'il existe pas
if (!file_exists($this->upload_dir)) {
files::makeDir($this->upload_dir, true);
}
# suppression de l'éventuel ancien fichier
if (isset($aCurrentFiles[$i]) && files::isDeletable($this->upload_dir . $aCurrentFiles[$i])) {
unlink($this->upload_dir . $aCurrentFiles[$i]);
}
$sDestination = $this->upload_dir . $iItemId . '-' . $j . '.' . $sExtension;
if (!move_uploaded_file($sUploadedFile['tmp_name'], $sDestination)) {
throw new Exception('Impossible de déplacer sur le serveur le fichier téléchargé.');
}
$aNewFiles[$j] = array('filename' => basename($sDestination), 'title' => !empty($_REQUEST[sprintf($this->config['files_title_patern'], $i)]) ? $_REQUEST[sprintf($this->config['files_title_patern'], $i)] : $j);
$j++;
} catch (Exception $e) {
$this->okt->error->set('Problème avec le fichier ' . $i . ' : ' . $e->getMessage());
}
}
return array_filter($aNewFiles);
}
示例7: editFiles
/**
* Modification des fichiers
*
* @return void
*/
protected function editFiles()
{
$aCurrentFiles = $this->getQuestion($this->params['id'])->getFilesInfo();
$aNewFiles = array();
foreach ($this->okt->languages->list as $aLanguage) {
$aNewFiles[$aLanguage['code']] = array();
$j = 1;
for ($i = 0; $i <= $this->config->files['number']; $i++) {
if (!isset($_FILES['p_files_' . $aLanguage['code'] . '_' . $i]) || empty($_FILES['p_files_' . $aLanguage['code'] . '_' . $i]['tmp_name'])) {
if (!empty($aCurrentFiles[$aLanguage['code']][$i])) {
$aNewFiles[$aLanguage['code']][$i] = $aCurrentFiles[$aLanguage['code']][$i]['filename'];
$j++;
}
continue;
}
$sUploadedFile = $_FILES['p_files_' . $aLanguage['code'] . '_' . $i];
try {
# des erreurs d'upload ?
util::uploadStatus($sUploadedFile);
# vérification de l'extension
$sExtension = pathinfo($sUploadedFile['name'], PATHINFO_EXTENSION);
if (!in_array($sExtension, explode(',', $this->config->files['allowed_exts']))) {
throw new Exception('Type de fichier non-autorisé.');
}
if (!file_exists($this->upload_dir)) {
files::makeDir($this->upload_dir, true);
}
if (!empty($aCurrentFiles[$aLanguage['code']][$i]) && files::isDeletable($this->upload_dir . $aCurrentFiles[$aLanguage['code']][$i]['filename'])) {
unlink($this->upload_dir . $aCurrentFiles[$aLanguage['code']][$i]['filename']);
}
$sDestination = $this->upload_dir . util::strToLowerURL($this->params['title'][$aLanguage['code']], false) . '-' . $aLanguage['code'] . '-' . $j . '.' . $sExtension;
if (!move_uploaded_file($sUploadedFile['tmp_name'], $sDestination)) {
throw new Exception('Impossible de déplacer sur le serveur le fichier téléchargé.');
}
$aNewFiles[$aLanguage['code']][] = basename($sDestination);
$j++;
} catch (Exception $e) {
$this->okt->error->set('Pour le fichier ' . $i . ' dans la langue ' . $aLanguage['code'] . ' : ' . $e->getMessage());
}
}
}
$this->params['files'] = $aNewFiles;
}