Create user directory on registration

2 months 3 weeks ago #317050 by 3cellhosting
Hello Kyle,

Thanks for the advice. There will be multiple files for each user.

I have uploaded a file to see the result and then checked the database as you suggested.

Quick question...

In the table comprofiler_plugin_gallery_items, the field called "value" is 32 characters long and ends .pdf - Is this simply a random number generated to avoid duplicate file names?

Many thanks for your input.


David - where personality, creativity and integrity come as standard.
2 months 3 weeks ago #317061 by krileon
The "value" column is the stored filename that's in the actual file system. The "file" column is the readable filename for the file. So for example if the file you upload is Test123.pdf you'd have Test123.pdf in "file" and "value" would typically be something randomly generated. This doesn't have to be the case though you can have "value" and "file" both user readable values it's entirely up to you and is there to avoid multiple uploads of same filename from overwriting each other.

Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Templates - CBSubs - Hosting - Forge - Incubator - GroupJive
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
Please note I am available Monday - Friday from 8:00 AM EST to 4:00 PM EST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
2 months 4 days ago #317394 by 3cellhosting
Hi Kyle,

Based on your advice I resolved my issue about saving to the gallery plugin. Each user could have multiple files and for ease of identification we created meaningful filenames to enable recognition by users.

We are using RSFormsPro and post processing of php. For completion of this post, incase anyone else has a similar need, this is the code we used to update the gallery plugin.
// Prepare variables
$delegate = $_POST['form']['RSEProName'];
$courseTitle = $_POST['form']['courseName'];
$delegateId = $_POST['form']['membershipId'];
$date = date("Y-m-d H:i:s");
$fileTitle = $delegate."-".$courseTitle."-".$SubmissionId.".pdf";

$path_to_directory = 'images/comprofiler/plug_cbgallery/'.$delegateId.'/files/';
if (!file_exists($path_to_directory) && !is_dir($path_to_directory)) {
    mkdir($path_to_directory, 0755, true);

// Set query for Comprofiler cbGallery plugin

$pdfName = $delegate.'-'.$courseTitle.'-'.$SubmissionId.'.pdf';
$jsonArray = [
	'name' => $pdfName,
	'extension' => 'pdf',
	'mimetype' => 'application\/pdf',
	'modified' => $date,
	'filesize' => 289565,
	'height' => 0,
	'width' => 0,
	'name_thumbnail' => $pdfName,
	'extension_thumbnail' => 'pdf',
	'mimetype_thumbnail' => 'application\/pdf',
	'modified_thumbnail' => $date,
	'filesize_thumbnail' => 289565,
	'height_thumbnail' => 0,
	'width_thumbnail' => 0

$jsonString = json_encode($jsonArray);

$db = JFactory::getDbo();

$query = $db->getQuery(true);
$columns = array('user_id','asset','type','value','file','folder','title','description','published','date','params');
$values = array($db->quote($delegateId), $db->quote('profile.'.$delegateId), $db->quote('files'), $db->quote($pdfName), $db->quote($pdfName), $db->quote('0'), $db->quote($courseTitle), $db->quote('CPPD Certificate'),  $db->quote('1'), $db->quote($date), $db->quote($jsonString));

// Prepare the insert query.
    ->values(implode(',', $values));


As usual, thank you for your advice.


David - where personality, creativity and integrity come as standard.
Moderators: beatnantkrileon
Time to create page: 0.397 seconds

Facebook Twitter LinkedIn