How upload file in Module

I need to upload a file in the opportunities module, but SUITE does not have a field for this type from the studio,
I have consulted and manipulated the code but I am not successful, someone could help me with this case

using SUITE 7.11.15

Hi @mmorales10 Welcome to the community,

It’s possible to add a file field to your custom or core module.

Check this post: SuiteCrm Upload File Field
It allows you to upload one file only.

If you want something more complicated, check this post:

Thanks,

BrozTechnologies

it is not very specific of how to do it could be clearer i am using suitecrm 7.11.15

https://community.sugarcrm.com/thread/22204

go to module/<module_name>/vardefs.php
add in fields array eg,

 'fields'=>array(
 // for image field
'photo' => array(
'name' => 'photo',
'vname' => 'LBL_PHOTO',
'type' => 'image',
'massupdate' => false,
'comments' => '',
'help' => '',
'importable' => false,
'reportable' => true,
'len' => 255,
'dbType' => 'varchar',
'width' => '160',
'height' => '160',
),
// for file
'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,
),
)

step 2 . do repair and rebuild and execute script query show in bottom of quick repair and rebuild page.
step3 . add these field in editview and detail view from studio

upload image and it will show in both view with remove buttom

1 Like

282/5000
Thank you very much, the file loads correctly but when I try to view it I get the following error:
Invalid File Reference.
this is the path its are trying to find:

index.php? preview = yes & entryPoint = download & id = d497b3d8-d7d9-4d03-d0f5-5f22c82566fe & type = Opportunities

Try to debug in download.php

I have a similar problem - but my problem is related to the fact that I am able to upload a file using editview - works great but when I try to upload a file in listview it doesnt do anything. The field stays empty (only shows a little eye icon). When I click on it then it says Invalid File Reference.

it is due to uploaded file deleted from upload folder , try with proper permission if not work create new folder for upload file and copy or move file from upload folder file name same as bean id in before logic hook , while download same copy file to upload folder from new folder then it will be definitely worked… same add filename in field by extracting from $_FILES request