Upload files under some user's folder

How to upload files to a user-specific folder in ChronoForms.

Overview

The issue occurs when the custom code uses an incorrect action ID and an incomplete file path, preventing the upload from targeting the correct user directory.
Ensure the custom code uses the correct numeric action ID from the Files Upload action and includes JPATH_BASE in the upload path to set the destination dynamically based on the logged-in user's username.

Answered
Ga Gatsman 14 May, 2014
Hello, i am following this tutorial:
http://www.chronoengine.com/faqs/53-cfv4/cfv4-file-uploads/2630-how-can-i-upload-files-under-some-users-folder.html
and this thread:
http://www.chronoengine.com/forums/posts/t90947/p315781.html

but i can't make it work no matter what i do :?

First of all i use Joomla 3 & ChronoForms V5, dont know if this code is working on it.

In Designer Tab
1 File Field (Field Name= file01, Field ID=file1)

In Setup Tab
1 Custom Code field with this code:
<?php
$user =& JFactory::getUser();
$form->set('upload_files_file1', 'upload_path', JOOMLA_PATH."/images/uploads/{$user->username}/");
?>


1 Files Upload (Files config=file01:jpg-png-gif, Upload path=images/file1)
Dont know if the images/file1 path is correct but thats where i want the users folder to be created and the files uploaded.

Anyone that can see what i am doing wrong?
Max_admin Max_admin 15 May, 2014
Hi Gatsman,

I have just added new section to the FAQ page with the code needed for v5 because its slightly different.

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Ga Gatsman 15 May, 2014
Thank you for updating the FAQ Max, but i still can't make it work 😒
It uploads the file but not where i want it, its either the default folder or whatever it put into the Files Upload - Edit action settings

This is the code in Custome Code before the Files Upload
<?php
$user =& JFactory::getUser();
$form->actions_config[file1]["upload_path"] = "images/uploadfiles/".DS.$user->get('username').DS;
?>


I could try and backup & upload my simple file upload form in case you want to take a look at it.
Thanks again
Max_admin Max_admin 15 May, 2014
"file1" is not a valid action id, the action id in v5 is written beside the action's name, with a sky blue background, and its a numeric value.

Moreover, the path in your code is incomplete, try to add JPAH_BASE to the start of the string!

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Ga Gatsman 15 May, 2014
Still can't make it work
Thanks for the id info didn't know that, its [1] for me.
The correct path must be
$form->actions_config[1]["path"] = JPATH_BASE.DS."images/uploadfiles".DS.$user->get('username').DS;
Ga Gatsman 15 May, 2014
Thats upload_path in my previous post
$form->actions_config[1]["upload_path"] = JPATH_BASE.DS."images/uploadfiles".DS.$user->get('username').DS;
Max_admin Max_admin 15 May, 2014
But why did you change it to "path" ? it should be "upload_path"!!πŸ™‚
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Max_admin Max_admin 15 May, 2014
And that still doesn't work ? please add a debugger action after the "files upload", also do you have the "custom code" before the "files upload" ?
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Ga Gatsman 15 May, 2014
I 've gone crazy trying everythingπŸ™‚ i saw it in the debugger
[path] => images\upload_files\20140515092804_G_background.png

and i thought i give it a try.

I always had a debugger on submit here are the PrtScr
Max_admin Max_admin 15 May, 2014
Answer
Your files upload id is "0" but not "1" as you have in the code!πŸ˜‰
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Ga Gatsman 15 May, 2014
Thank you Max πŸ˜› πŸ˜› πŸ˜›

I was looking on another id and came with the 1...
This topic is locked and no more replies can be posted.