linea21-core
[ class tree: linea21-core ] [ index: linea21-core ] [ all elements ]

Source for file upload.php

Documentation is available at upload.php

  1. <?php
  2. /**
  3.  * @package linea21.core
  4.  * @subpackage library
  5.  * @author Simon Georget <simon@linea21.com>
  6.  * @version $id SVN
  7.  * @access public
  8.  * @license http://opensource.org/licenses/gpl-3.0.html
  9.  */
  10.  
  11. //header('Content-type: application/json');
  12. //header('Content-type: text/plain');
  13. include_once('../config/define.php');
  14.  
  15. $foldername $_REQUEST['foldername'];
  16. $id $_REQUEST['id'];
  17. $file $_FILES['file'];
  18.  
  19. if(!$l21auth->isWorkgroupUser($id$sql_object)) die('no way!');
  20.  
  21. if (!empty($_FILES)) {
  22.   $tempFile $_FILES['file']['tmp_name'];
  23.   $file $_FILES['file'];
  24.   $filename_parts pathinfo($_FILES['file']['name']);
  25.   $filename cleanString($filename_parts['filename']).'.'.$filename_parts['extension'];
  26.  
  27.   $targetPath dirname(__FILE__)DIRECTORY_SEPARATOR 'userfiles'DIRECTORY_SEPARATOR 'workgroups' DIRECTORY_SEPARATOR $foldername DIRECTORY_SEPARATOR;
  28.  
  29.   $targetFile str_replace('//','/',$targetPath$filename;
  30.  
  31.   if (in_array(strtolower($filename_parts['extension']),explode(','MEDIA_ALLOWED_EXT))) {
  32.     if(!file_exists(str_replace('//','/',$targetPath)))
  33.     mkdir(str_replace('//','/',$targetPath)0755true);
  34.  
  35.     move_uploaded_file($tempFile,$targetFile);
  36.     echo '{"name":"'.$filename.'","type":"'.$file['type'].'","size":"'.$file['size'].'"}';
  37.   else {
  38.     echo '{"error" : "File transfer error"}';
  39.   }
  40. }
  41. ?>

Documentation generated on Thu, 20 Mar 2014 16:49:44 +0100 by phpDocumentor 1.4.1