AnsweredAssumed Answered

Cases  "Upload File" how to save the file that I have chose ?

Question asked by Dimitrij Dimitrij on Mar 23, 2015
I am trying to save file in Cases module ,but it 's not working,  what I'm doing wrong  ??
Please help me ..!!!

I'm wusing Sugar 6.5.x CE

Dis what i have done so fare :

In (  /custom/Extension/modules/moduleName/Ext/Vardefs/ ) I have added  file.php file whit 
************************************************************************************************
<?php
$dictionary["Case"]["fields"]["uploadfile_c"] = array( 'name' => 'uploadfile_c',
'vname' => 'LBL_UPLOADFILE_C',
'type' => 'file',
'dbType' => 'varchar',
'len' => '255',
'reportable'=>true,
'importable' => false,
);
?>

<?php
$dictionary["Case"]["fields"]["file_name"] =
    array (
        'name' => 'file_name',
        'vname' => 'LBL_FILENAME',
        'type' => 'varchar',
        'len' => '255',
    );  
?>

<?php
$dictionary["Case"]["fields"]["file_url_c"] = array(
'name'=>'file_url_c',
'vname' => 'LBL_FILE_URL_C',
'type'=>'function',
'function_class'=>'UploadFile',
'function_name'=>'get_upload_url',
'function_params'=> array('$this'),
'source'=>'function',
'reportable'=>false,
'importable' => false,
);
?>

<?php
$dictionary["Case"]["fields"]["file_mime_type_c"] = array(
'name' => 'file_mime_type_c',
'vname' => 'LBL_FILE_MIME_TYPE_C',
'type' => 'varchar',
'len' => '100',
'importable' => false,
);
?>
***************************************************************************************************


And in \custom\modules\moduleName\metadata\editviewdefs.php.  I have add :
***********************************************************************
'templateMeta' =>     array (
      'maxColumns' => '2',
      'widths' => 
      array (
        0 => 
        array (
          'label' => '10',
          'field' => '30',
        ),
        1 => 
        array (
          'label' => '10',
          'field' => '30',
        ),
      ),
      'form' => 
      array (
        'enctype' => 'multipart/form-data',
        ),

********************************************************************


And in Cases.php , in function save() I have add :
***************************************************************************
function save($check_notify = FALSE){ 
 require_once('include/upload_file.php');       
 $upload_file = new UploadFile('uploadfile_c');
        $do_final_move = false;
        if(isset($_FILES['uploadfile_c']) && $upload_file->confirm_upload()) {
            $this->file_name = $upload_file->get_stored_file_name();
            $this->file_mime_type_c = $upload_file->mime_type;
            $do_final_move = true;
        }            
        parent::save();
        if ($do_final_move)
                       $upload_file->final_move($this->id);

}
***************************************************************************


I add the uploadfile_c in editviewdefs.php  and the browsering the file it OK it is working, but when I chose some file  and clixk on Save .. it's not saving the file in Upload folder ....:(
What  I'm doing wrong ..??

Please can some one help me  with my problem ..  ??

Thank you..
:)

Outcomes