public function add($source, $fileName, $parent)
    {
        if (! \tao_helpers_File::securityCheck($fileName, true)) {
            throw new \common_Exception('Unsecured filename "'.$fileName.'"');
        }

        if (($resource = fopen($source, 'r')) === false) {
            throw new \common_Exception('Unable to read content of file ("' . $source . '")');
        }

        $file = $this->getItemDirectory()->getDirectory($parent)->getFile($fileName);
        $writeSuccess = $file->put($resource);
        fclose($resource);

        if (! $writeSuccess) {
            throw new \common_Exception('Unable to write file ("' . $fileName . '")');
        }

        return $this->getInfoFromFile($file);
    }
public function add($source, $fileName, $parent)
    {
        if (! \tao_helpers_File::securityCheck($fileName, true)) {
            throw new \common_Exception('Unsecured filename "'.$fileName.'"');
        }

        if (($resource = fopen($source, 'r')) === false) {
            throw new \common_Exception('Unable to read content of file ("' . $source . '")');
        }

        $file = $this->getItemDirectory()->getDirectory($parent)->getFile($fileName);
        $writeSuccess = $file->put($resource);
        fclose($resource);

        if (! $writeSuccess) {
            throw new \common_Exception('Unable to write file ("' . $fileName . '")');
        }

        return $this->getInfoFromFile($file);
    }
public function add ( $ source , $ fileName , $ parent ) { if ( ! \ tao_helpers_File :: securityCheck ( $ fileName , true ) ) { throw new \ common_Exception ( 'Unsecured filename "' . $ fileName . '"' ) ; } if ( ( $ resource = fopen ( $ source , 'r' ) ) === false ) { throw new \ common_Exception ( 'Unable to read content of file ("' . $ source . '")' ) ; } $ file = $ this -> getItemDirectory ( ) -> getDirectory ( $ parent ) -> getFile ( $ fileName ) ; $ writeSuccess = $ file -> put ( $ resource ) ; fclose ( $ resource ) ; if ( ! $ writeSuccess ) { throw new \ common_Exception ( 'Unable to write file ("' . $ fileName . '")' ) ; } return $ this -> getInfoFromFile ( $ file ) ; }
Add content to file

@see \oat\tao\model\media\MediaManagement::add
@param string $source
@param string $fileName
@param string $parent
@return array
@throws \common_Exception
@throws \tao_models_classes_FileNotFoundException
Add content to file