Module Loader - file_get_contents restriction

as per official guide teh file_get_contents() function is disabled by default.

Of course you could override this behaviour but i would use alternative method provided by Suite.

I’ve cerated a zip package that execute a post install script which should retrieve a file content.

the alternative method looks like:


$uploadFile = new UploadFile();

//get the file location
$uploadFile->temp_file_location = UploadFile::get_upload_path($file_id);
$file_contents = $uploadFile->get_file_contents();

But how retrieve a specific file content inside a specific folder(ex: subdirectory inside my scripts folder in the zip package) if i don’t know the $file_id?

How to passing the right file_id?

Thank you for any hint.


Whose “official documentation” is that? And where does it say " file_get_contents() function is disabled by default"? I don’t find that there… :huh:

It seems the UploadFile class is for files you upload into SuiteCRM as Docuements/Attachements/etc. I wouldn’t use it unless that is really the sort of object you want to handle.

I’m not sure exactly what your requirements are, but i would say If you’re just doing your own processing, stick to the regular PHP functions. You will surely find many examples of handling stuff inside zips. Then when you have your data sorted out you can put into SuiteCRM objects.

Not sure this helps, but it’s the best advice I can give with what I know…

thank for your quick reply.

Regarding file_get_content() i’ve tried by myself…so after adding a specific override in config this traditional php function had worked:

 $sugar_config['disable_persistent_connections'] = false;
$sugar_config['moduleInstaller']['blackListExempt'] = array(

My needs is to distribute inside a zip package a .sql files in order to make an initial sql query to insert some defaults records(ex: acl roles).

So what i’ve done so far is:

  1. set config_override
  2. upload package
  3. distribute files with manifest
  4. launch post_install script which get sql file contents and execute insert query.

What i would do is to avoid to insert the config_override and use safer methods.


I’m sorry, I never used that UploadFile class and I don’t know exactly how it is meant to be used…

From a brief view, it looks like it’s meant for files uploaded into SuiteCRM (through notes and attachments) so probably you can get the file_id if you are able to upload it along with one of those beans. But I might be completely lost on this.

This might (just maybe!) help:

I would also try a crazy test: put the file in the “upload” folder with a name like the typical SuiteCRM ids:


Then use that as file_id to see if it fetches the file…

Or even simpler, given the way this is written:

Just give it a path directly and it should load the contents:

$uploadFile->temp_file_location = 'upload/YourFile.sql';
$file_contents = $uploadFile->get_file_contents();