Inheritance: extends CWidget
Example #1
0
 /**
  * @return Action_Helper_Plupload
  */
 public function init()
 {
     $request = $this->getRequest();
     if ($request->getParam('plupload', false)) {
         Plupload::OnMultiFileUpload(CS_TMP_TPL_DIR);
     }
     return $this;
 }
 public function upload()
 {
     return \Plupload::file('file', function ($file) {
         // Store the uploaded file
         $file->move(storage_path() . '/files', $file->getClientOriginalName());
         // This will be included in JSON response result
         return ['success' => true, 'message' => 'Upload successful.', 'file' => $file->getClientOriginalName()];
     });
 }
Example #3
0
 public function postAvatar()
 {
     return \Plupload::receive('file', function ($file) {
         // Store the uploaded file
         $email = \Auth::user()->email;
         $path = storage_path() . '/profiles/' . $email . '/avatar/';
         if (!file_exists($path)) {
             \File::makeDirectory($path, $mode = 0777, $recursive = true);
             $path = storage_path() . '/profiles/' . $email . '/avatar/avatar.jpg';
             \Image::make($file->getRealPath())->save($path, 30);
         }
         $path = storage_path() . '/profiles/' . $email . '/avatar/avatar.jpg';
         if (file_exists($path)) {
             chown($path, 465);
             unlink($path);
         }
         \Image::make($file->getRealPath())->fit(1000, 1000)->save($path, 30);
     });
 }
Example #4
0
 public function uploadAction()
 {
     global $Campsite;
     $auth = Zend_Auth::getInstance();
     $userId = $auth->getIdentity();
     $_FILES['file']['name'] = preg_replace('/[^\\w\\._]+/', '', $_FILES['file']['name']);
     $mimeType = $_FILES['file']['type'];
     $type = explode('/', $mimeType);
     if ($type[0] == 'image') {
         $file = Plupload::OnMultiFileUploadCustom($Campsite['IMAGE_DIRECTORY']);
         $image = Image::ProcessFile($_FILES['file']['name'], $_FILES['file']['name'], $userId, array('Source' => 'feedback', 'Status' => 'Unapproved', 'Date' => date('Y-m-d')));
         $this->view->response = $image->getImageId();
     } else {
         if ($type[1] == 'pdf') {
             $attachment = new Attachment();
             $attachment->makeDirectories();
             $file = Plupload::OnMultiFileUploadCustom($attachment->getStorageLocation());
             $document = Attachment::ProcessFile($_FILES['file']['name'], $_FILES['file']['name'], $userId, array('Source' => 'feedback', 'Status' => 'Unapproved'));
             $this->view->response = $document->getAttachmentId();
         }
     }
 }
Example #5
0
<?php
/**
 * @package Campsite
 *
 * @author Holman Romero <*****@*****.**>
 * @copyright 2010 Sourcefabric o.p.s.
 * @license http://www.gnu.org/licenses/gpl.txt
 * @link http://www.sourcefabric.org
 */

require_once($GLOBALS['g_campsiteDir']. "/classes/Plupload.php");

if (!$g_user->hasPermission('AddImage')) {
    camp_html_display_error(getGS("You do not have the right to add images."));
    exit;
}

// Plupload
$files = Plupload::OnMultiFileUpload($Campsite['IMAGE_DIRECTORY']);
?>
 public function upload()
 {
     if (Session::get('isLogged') == true) {
         return \Plupload::file('file', function ($file) {
             // екстракт на наставката
             $originName = $file->getClientOriginalName();
             $array = explode('.', $originName);
             $extension = end($array);
             // името без наставка
             $name = self::normalizeString(pathinfo($originName, PATHINFO_FILENAME));
             // base64 од името на фајлот
             $fileName = base64_encode($name) . '.' . $extension;
             // пат до фајлот
             $path = storage_path() . '\\upload\\' . Session::get('index') . '\\' . $fileName;
             if (!File::exists($path)) {
                 // фајловите се чуваат во storage/upload/brIndeks/base64(filename).extension
                 $file->move(storage_path('upload/' . Session::get('index')), $fileName);
                 return ['success' => true, 'message' => 'Upload successful.', 'deleteUrl' => action('FileController@delete', [$file])];
             } else {
                 return ['success' => false, 'message' => 'File with that name already exists!', 'deleteUrl' => action('FileController@delete', [$file])];
             }
         });
     } else {
         abort(404);
     }
 }
Example #7
0
<?php
/**
 * @package Newscoop
 *
 * @author Mihai Nistor <*****@*****.**>
 * @copyright 2010 Sourcefabric o.p.s.
 * @license http://www.gnu.org/licenses/gpl.txt
 * @link http://www.sourcefabric.org
 */

require_once($GLOBALS['g_campsiteDir']. "/classes/Plupload.php");
require_once($GLOBALS['g_campsiteDir'].'/classes/Attachment.php');

if (!$g_user->hasPermission('AddFile')) {
	camp_html_display_error(getGS("You do not have the right to add files."));
	exit;
}

$attachmentObj = new Attachment();
$attachmentObj->makeDirectories();
// Plupload
$files = Plupload::OnMultiFileUpload($attachmentObj->getStorageLocation());
?>
Example #8
0
 public function uploadAction()
 {
     $this->_helper->layout->disableLayout();
     global $Campsite;
     $files = Plupload::OnMultiFileUpload($Campsite['IMAGE_DIRECTORY']);
     //var_dump($files);
     die;
 }
 public function postUseravatar()
 {
     return \Plupload::receive('file', function ($file) {
         // Store the uploaded file
         $email = \Request::input('email');
         $path = storage_path() . '/profiles/' . $email . '/avatar/';
         \File::makeDirectory($path, $mode = 0777, $recursive = true);
         $path = storage_path() . '/profiles/' . $email . '/avatar/avatar.jpg';
         \Image::make($file->getRealPath())->save($path, 30);
     });
 }
<?php
/**
 * @package Campsite
 *
 * @author Holman Romero <*****@*****.**>
 * @copyright 2010 Sourcefabric o.p.s.
 * @license http://www.gnu.org/licenses/gpl.txt
 * @link http://www.sourcefabric.org
 */
 
require_once($GLOBALS['g_campsiteDir']. "/classes/Plupload.php");

if (!$g_user->hasPermission('ManageTempl')) {
	camp_html_display_error(getGS("You do not have the right to modify templates."));
	exit;
}

// Plupload
$files = Plupload::OnMultiFileUpload(CS_TMP_TPL_DIR);
?>