Hello,
At first thanks for this great component! Chronoforms rocks!😀
Im trying to save my uploaded files through the upload files gh action, and im wondering if its possible to save them (default) under the logged in username directory in the images directory.
Can I change the "upload_files_gh.php" so it will automaticly saves them in the (joomla)/images/username/ directory?
Thanks in advance,
Peter de Wit
The Netherlands
At first thanks for this great component! Chronoforms rocks!😀
Im trying to save my uploaded files through the upload files gh action, and im wondering if its possible to save them (default) under the logged in username directory in the images directory.
Can I change the "upload_files_gh.php" so it will automaticly saves them in the (joomla)/images/username/ directory?
Thanks in advance,
Peter de Wit
The Netherlands
Hi Peter,
Note: you probably need to improve this code to make sure that you handle any usernames with spaces or special characters correctly; and to handle guests if they have form access.
Bob
You may use form inputs e.g. {input_name} in the path*.
So you need to use a Custom Code action to add the username to the $form->data array like this:<?php
$user=& JFactory::getUser();
$form->data['username'] = $user->username;
?>Then you can use {username} in the Path or File name box.Note: you probably need to improve this code to make sure that you handle any usernames with spaces or special characters correctly; and to handle guests if they have form access.
Bob
Hello Bob,
Thanks for the fast respons, but the question is a little bit more complicated. I'm using this code:
but the problem is that it won't write the file to the url but needs the absolute path like in the default value (/var/www/vhosts/6/111082/webspace/httpdocs/*website.url*/components/com_chronoforms/uploads/{form_name}/)
I would like to edit/change this value into /var/www/vhosts/6/111082/webspace/httpdocs/*website.url*/images/{name}
The idea behind this is to make it possible to use this as a template so I need relative paths 🙂
Thanks in advance,
Peter de Wit
the Netherlands
Thanks for the fast respons, but the question is a little bit more complicated. I'm using this code:
<?php
$name = 'Guest';
if (!JFactory::getUser()->guest) {
$name = JFactory::getUser()->name;
}
$photo = JURI::Base().'/images/'.$name.'/';
?>
<input id="hidden" type="hidden" value="1" name="cf_id" />
<input id="name" type="hidden" value='<?php echo $photo;?>' name="photo" />but the problem is that it won't write the file to the url but needs the absolute path like in the default value (/var/www/vhosts/6/111082/webspace/httpdocs/*website.url*/components/com_chronoforms/uploads/{form_name}/)
I would like to edit/change this value into /var/www/vhosts/6/111082/webspace/httpdocs/*website.url*/images/{name}
The idea behind this is to make it possible to use this as a template so I need relative paths 🙂
Thanks in advance,
Peter de Wit
the Netherlands
Hi Peter,
I went back and checked my code. Please try putting {root_path}\images\{username} in the Path box and forget the PHP code, it shouldn't be needed.
Bob
PS I see that I allowed for {form_name}, {root_path}, {random}, {username}, {datetime} in the code - they are mentioned right at the bottom of the Help tab (except that says wrongly {rand} instead of {random}).
I went back and checked my code. Please try putting {root_path}\images\{username} in the Path box and forget the PHP code, it shouldn't be needed.
Bob
PS I see that I allowed for {form_name}, {root_path}, {random}, {username}, {datetime} in the code - they are mentioned right at the bottom of the Help tab (except that says wrongly {rand} instead of {random}).
This topic is locked and no more replies can be posted.
