uploading a file in core module

I have created a file type field in accounts module and I want the uploads files to get saved in my custom path rather than in uploads folder can any one help me out ?
  • Hi Dev,

    There are two ways of uploading a file in core module.

    1. You can change the path of upload_dir in sugar configuration file, but this will be applicable to the upload feature as a whole.
    2. You can create custom file type field to achieve this.
    Rolustech: SugarCRM Engineering
    Website: www.rolustech.com
    Ph (US): +1 - 310 - 492 - 5564
    Ph (UK): +44 - 207 - 9938 - 524
    Email: info@rolustech.com
    Skype: rolustech
  • Can you provide any details on "how" to create a custom file type field?

  • Hi Robert,

    In which module you would like to add the file type field. I can provide you the code sample accordingly.

    Thanks!

  • Hi Shijin,

    I actually need to do this to a custom module - not a core module, but we are quite familiar with Sugar in general and custom coding so if you have an example of adding a File field to one module, I'm fairly confident we can apply that to other modules.  I've seen snippets of code describing what is needed - but have not found a complete explanation that clearly identifies all the places that need to be touched - and as I'm sure you well know - one missing detail in Sugar can have significant cascading results!

    I've actually been trying to figure out how to enable the ability to add a file field in Studio and/or Module Builder - the templates etc. seem to exist - but the plumbing is not connected! I ultimately need to add a file upload fields to a number of modules.

    Thanks for any help you can provide!

  • Hi Robert,

    I am not sure this reply will be relevant for you now.

    Here is my blog post which explains how to add a file upload field to Core modules and Custom modules which are not of template type file.

    Creating a File Upload Field for a Core Module/Custom Module in Sugar 7.x | Bhea Blogs

    Please have a look and let me know if you need any assistance.

    Thanks!

  • Hello Shijin Krishna , Do you have any insight on this please?

    Been trying to make this change for a core module ( Contracts ) this whole morning but it simply refuses to work , while it does in a module like Cases for example.  The only explanation I could think of is that the Contracts is a BWC module and doesn't have a recordview ? The field gets detected , I make the changes in the database to add filename and mimetype fields. But when uploading a file nothing happens.

  • Hi All,

                I am also unable to create a file type field for the contracts module following the above links.

    I am able tou upload but the file is not saving.

    Can any one please provide an insight in to this.

    File:custom/Extension/modules/Contracts/Ext/Vardefs/file.php

    <?php

    $GLOBALS['dictionary']['Contract']['fields']['filename'] = array (

         'name' => 'filename',

         'vname' => 'LBL_FILENAME',

         'type' => 'file',

         'dbType' => 'varchar',

         'len' => '255',

         'reportable' => true,

         'comment' => 'File name associated with the note (attachment)',

         'importable' => false,

    );

    $GLOBALS['dictionary']['Contract']['fields']['file_mime_type'] = array(

         'name' => 'file_mime_type',

         'vname' => 'LBL_FILE_MIME_TYPE',

         'type' => 'varchar',

         'len' => '100',

         'comment' => 'Attachment MIME type',

         'importable' => false,

    );

    $GLOBALS['dictionary']['Contract']['fields']['file_url'] = array (

         'name' => 'file_url',

         'vname' => 'LBL_FILE_URL',

         'type' => 'varchar',

         'source' => 'non-db',

         'reportable' => false,

         'comment' => 'Path to file (can be URL)',

         'importable' => false,

    );

    I  have done a qrr went to studio and added the field for the edit and detail view.

    The upload button is coming but the file is not saving.

    Regards

    Sidhu Tevfik Tümer Angel Magana David López

  • Hi All,

                  I was able to create the file field using the link 

    making a file type field in sugarcrm custom module - Stack Overflow 

    But i am unable to figure out where exactly the id(name) of the file is stored in the db which matches to the upload directory

    Regards

    Sidhu Tevfik Tümer Angel Magana David López

  • Hi sidhu,

    I'm also looking for creating custom field for file upload. How did you solve this problem?

    thanks.

  • Hi sidhu, How did you solve this issue?