/**
  * Upload media file ,like: image/flash
  *
  * @author  John.meng (цот╤РШ)
  * @since   version - 2006-1-7 12:56:23
  * @param   string  
  *
  */
 function uploadMedia($CurrentUserPathImages, $oldPic = "", $PicType = "Pic", $newWidth = "", $newHeight = "", $CreateIco = false, $IcoWidth = "", $IcoHeight = "")
 {
     $allowed_mimetypes = array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/x-png', 'application/x-shockwave-flash');
     $maxfilesize = 10000000;
     $FileUploaderObj = new FileUploader($CurrentUserPathImages, $allowed_mimetypes, $maxfilesize);
     $FileUploaderObj->newWidth = $newWidth;
     $FileUploaderObj->newHeight = $newHeight;
     if ($CreateIco && $IcoWidth && $IcoHeight) {
         $FileUploaderObj->CreateIco = $CreateIco;
         $FileUploaderObj->IcoWidth = $IcoWidth;
         $FileUploaderObj->IcoHeight = $IcoHeight;
     }
     if ($_FILES[$PicType]['name'] != "") {
         if ($FileUploaderObj->fetchMedia($PicType)) {
             $FileUploaderObj->setPrefix($PicType . "_");
             if (!$FileUploaderObj->upload()) {
                 echo $FileUploaderObj->getErrors();
             } else {
                 $StrPic = $FileUploaderObj->getSavedFileName();
                 if ($oldPic) {
                     @unlink($CurrentUserPathImages . "/" . $oldPic);
                 }
             }
         }
     } else {
         $StrPic = $oldPic;
     }
     return $StrPic;
 }
Esempio n. 2
0
 public function upload()
 {
     global $varChecker;
     if ($varChecker->getValue('fileindex') !== false) {
         $fileindex = $varChecker->getValue('fileindex');
         $fileindex = empty($fileindex) ? 0 : $fileindex;
         $handle = $this->findFilehandle($fileindex);
     } else {
         $handle = $this->findFilehandle();
     }
     $uploader = new FileUploader($handle, true);
     $error = '';
     $path = 'cache/templates/' . $this->INK_User->getCustomer()->getSite()->getId() . '/';
     $fmaker = new FileMaker();
     $fmaker->makeDirectory($path, false);
     //upload the file
     try {
         //upload to cms
         $path = $uploader->upload($path);
         //upload to client server
         $result = array('success' => 'file_uploaded', 'filepath' => $path, 'msg' => 'file uploaded');
     } catch (Exception $e) {
         $result = array('error' => $e->getMessage());
     }
     echo json_encode($result);
 }
 /**
  * 
  * @param array $file e.g. $_FILES['photo']
  * @return ConversationAttachment
  */
 public function addAttachment($file)
 {
     $systemFilename = self::findNewFileName($this->config->uploadDir);
     $attachsImgUpConfig = $this->config->imageUploaderConfig;
     $attachsImgUpConfig->uploadDir = $this->config->uploadDir;
     if (in_array($file["type"], $attachsImgUpConfig->acceptedMimeTypes->toArray())) {
         ImageUploader::upload($file, $systemFilename, $attachsImgUpConfig);
     } else {
         FileUploader::upload($file, $systemFilename, $this->config->uploadDir);
     }
     $qb = new QueryBuilder();
     $qb->insert(Tbl::get('TBL_CONVERSATION_ATTACHEMENTS'))->values(array('system_filename' => $systemFilename, 'filename' => $file['name'], 'mime_type' => $file['type']));
     $attachmentId = $this->query->exec($qb->getSQL())->getLastInsertId();
     $filter = new ConversationAttachmentFilter();
     $filter->setId($attachmentId);
     return $this->getAttachment($filter);
 }
Esempio n. 4
0
 /**
  * @copydoc FileUploader::upload
  *
  * @throws SystemException 'ERR_BAD_FILE_FORMAT'
  */
 public function upload($dir)
 {
     if ($this->getExtension() != 'flv' && file_exists($this->getConfigValue('video.ffmpeg'))) {
         $cmd = $this->getConfigValue('video.ffmpeg') . ' -i ' . $this->file['tmp_name'] . ' -f flv -y  -ar 22050 -ab 32 -b 700000 -s cif ' . ($this->FileObjectName = $this->generateFilename($dir, 'flv'));
         $returnStatus = false;
         /*$result = */
         system($cmd, $returnStatus);
         if ($returnStatus) {
             throw new SystemException('ERR_BAD_FILE_FORMAT', SystemException::ERR_CRITICAL, $this->file['name']);
         }
         $cmd = $this->getConfigValue('video.ffmpeg') . ' -i ' . $this->file['tmp_name'] . ' -vframes 1 -ss 00:00:05' . ' -f image2 -s cif -an ' . $this->FileObjectName . '.jpg';
         system($cmd);
         $result = true;
     } else {
         $result = parent::upload($dir);
     }
     return $result;
 }
Esempio n. 5
0
{
    if (isset($array[$value])) {
        return $array[$value];
    } else {
        return "";
    }
}
//Form parameters
$form_action = "uploadhymn.php";
$form_legend = "Ladda upp psalm";
if (isset($_FILES["file"])) {
    $dirs = array("audio/mpeg" => "mp3", "video/ogg" => "ogg", "audio/midi" => "midi");
    $target_dir = "../hymns/" . take($dirs, $_FILES["file"]["type"]) . "/";
    $formats = array("video/ogg", "audio/midi", "audio/mpeg");
    $uploader = new FileUploader();
    if ($uploader->upload($_FILES["file"], $target_dir, $formats)) {
        $form_message = "Filen har laddats upp.";
    } else {
        $form_message = $uploader->error();
    }
}
?>

<html>
  <head>
    <title>Online-Psalmboken</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  </head>
  <body>
    <p>
      <a href="index.php">Start</a> &raquo;
<?php

require 'authentication.php';
require 'fileuploader.php';
//Form parameters
$form_action = "uploadhymnbook.php";
$form_legend = "Ladda upp psalmbok";
if (isset($_FILES["file"])) {
    $uploader = new FileUploader();
    if ($uploader->upload($_FILES["file"], "../xml/hymnbooks/", array("text/xml"))) {
        $form_message = "Filen har laddats upp.";
    } else {
        $form_message = $uploader->error();
    }
}
?>

<html>
  <head>
    <title>Online-Psalmboken</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  </head>
  <body>
    <p>
      <a href="index.php">Start</a> &raquo;
      <a href="">Ladda upp psalmbok</a>
    </p>
    <?php 
require 'uploadform.php';
?>
  </body>
Esempio n. 7
0
/**
 * Base config file
*/
require_once realpath(dirname(__FILE__)) . '/../../config_path.inc.php';
/**
 * Clear node and layout variable in $_SESSION
*/
$variableToClearAR = array('node', 'layout', 'course', 'user');
/**
 * Users (types) allowed to access this module.
*/
$allowedUsersAr = array(AMA_TYPE_SWITCHER);
/**
 * Get needed objects
*/
$neededObjAr = array(AMA_TYPE_SWITCHER => array('layout'));
/**
 * Performs basic controls before entering this module
*/
require_once ROOT_DIR . '/include/module_init.inc.php';
require_once ROOT_DIR . '/browsing/include/browsing_functions.inc.php';
require_once ROOT_DIR . '/include/FileUploader.inc.php';
$fileUploader = new FileUploader(ADA_UPLOAD_PATH);
if ($fileUploader->upload() == false) {
    $data = $fileUploader->getErrorMessage();
} else {
    $_SESSION['importHelper']['filename'] = $fileUploader->getPathToUploadedFile();
    $data = '1';
    // '1' means okay
}
echo $data;
Esempio n. 8
0
require_once realpath(dirname(__FILE__)) . '/../../../../config_path.inc.php';
/**
 * Clear node and layout variable in $_SESSION
*/
$variableToClearAR = array('node', 'layout', 'course', 'user');
/**
 * Users (types) allowed to access this module.
*/
$allowedUsersAr = array(AMA_TYPE_SWITCHER, AMA_TYPE_STUDENT, AMA_TYPE_AUTHOR, AMA_TYPE_TUTOR);
/**
 * Get needed objects
*/
$neededObjAr = array(AMA_TYPE_STUDENT => array('layout'), AMA_TYPE_SWITCHER => array('layout'), AMA_TYPE_AUTHOR => array('layout'), AMA_TYPE_TUTOR => array('layout'));
/**
 * Performs basic controls before entering this module
*/
$trackPageToNavigationHistory = false;
require_once ROOT_DIR . '/include/module_init.inc.php';
require_once ROOT_DIR . '/browsing/include/browsing_functions.inc.php';
require_once ROOT_DIR . '/include/FileUploader.inc.php';
$fileUploader = new FileUploader(ADA_UPLOAD_PATH . $userId . '/');
// $fieldUploadName);
if ($fileUploader->upload(true) == false) {
    $data = $fileUploader->getErrorMessage();
} else {
    $_SESSION['uploadHelper']['filename'] = $fileUploader->getPathToUploadedFile();
    $_SESSION['uploadHelper']['fileNameWithoutPath'] = $fileUploader->getFileName();
    $data = '1';
    // '1' means okay
}
echo $data;