File size: 976 Bytes
07c3cdd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
namespace ProcessMaker\BusinessModel;

use \G;

class File
{
    /**
     * Upload file
     *
     * @param array  $aData
     */
    public function uploadFile($aData)
    {
        try {
            if ($_FILES['file_content']['error'] != 1) {
                if ($_FILES['file_content']['tmp_name'] != '') {
                    $aAux = explode('.', $_FILES['file_content']['name']);
                    $content = file_get_contents($_FILES['file_content']['tmp_name']);
                    $result = array('file_content' => $content);

                    \G::uploadFile($_FILES['file_content']['tmp_name'], PATH_DOCUMENT.'/upload/', $_FILES['file_content']['name']);
                }
            } else {
                $result->success = false;
                $result->fileError = true;
                throw (new \Exception($result));
            }
            return $result;
       
        } catch (\Exception $e) {
            throw $e;
        }
    }
}