Currently, all attachments are uploaded into root folder on the server's appgini instance. It would be much cleaner to have a dedicated subfolder for attachments, but I don't see that option in the application. I thought of searching inside the appgini file(s) and code to customize and make this happen, but there may be some side effects that I don't know about. Can anyone point me to where I can customize the uploaded attachments location?
Thanks,
~Bob
change path to attachment files
Re: change path to attachment files
Hmm .. by default, attachments should go to the "images" folder. You can control this by editing the generated "defaultLang.php" .. Find the line starting with
Code: Select all
$Translation['ImageFolder']
AppGini plugins to add more power to your apps:
- DataTalk is an innovative AppGini plugin based on ChatGPT that allows you to interact with your AppGini database using natural language questions, without writing any SQL. Check the demo video
- Mass Update plugin: Update multiple records at once and improve your workflow efficiency.
- Check our other plugins and get a generous discount of up to 30% when buying 2 or more plugins.
Re: change path to attachment files
I checked the path, and it's at the default you mentioned - $Translation['ImageFolder'] = './images/';
There must have been some corruption, but I fixed it by changing the path to a new folder, which worked, then reverting to /images/, which now works as expected.
Thanks for your timely reply!
~Bob
There must have been some corruption, but I fixed it by changing the path to a new folder, which worked, then reverting to /images/, which now works as expected.
Thanks for your timely reply!
~Bob
Re: change path to attachment files
Hi,
I'm trying to organise the images, and I'm working around and still couldn't get it.
I have a record (main table) with ex. the field "name of a person" and then a subtable with the fields "image name" and "image file"
So I would like that when I upload a specific image on the subtable that it wouldbe created as:
- first created a folder with the "name of the person" field from the main table,
- and then store the upoad the image with the name i had specify on the field "image name".
And aftwards, if I delete the record the main table, to be able to delete all the folders as well their contents.
Can anyone help on this,
Thks
I'm trying to organise the images, and I'm working around and still couldn't get it.
I have a record (main table) with ex. the field "name of a person" and then a subtable with the fields "image name" and "image file"
So I would like that when I upload a specific image on the subtable that it wouldbe created as:
- first created a folder with the "name of the person" field from the main table,
- and then store the upoad the image with the name i had specify on the field "image name".
And aftwards, if I delete the record the main table, to be able to delete all the folders as well their contents.
Can anyone help on this,
Thks
Re: change path to attachment files
i tell you about my project
i have table name Attachments
i save Attach files in sub folders . sub folders name by ProfileNo
you should make Attachments folder in your project folder
this code in hooks/attachments.php
to view Attachment files you should make change in
templates/Attachments_templateTV.html
i have table name Attachments
i save Attach files in sub folders . sub folders name by ProfileNo
you should make Attachments folder in your project folder
this code in hooks/attachments.php
Code: Select all
function Attachments_init(&$options, $memberInfo, &$args){
global $Translation;
// if($_REQUEST['filterer_ProfileNo']=='') $options->AllowInsert = FALSE;
$Translation['ImageFolder'] = './Attachments/' . $_REQUEST['filterer_ProfileNo'] . "/";
return TRUE;
}
to view Attachment files you should make change in
templates/Attachments_templateTV.html
Code: Select all
<td id="Attachments-AttachmentFile-<%%VALUE(AttachmentID)%%>" class="Attachments-AttachmentFile text-right"><a href="link.php?t=Attachments&f=AttachmentFile&i=<%%VALUE(AttachmentID)%%>&p=<%%VALUE(ProfileNo)%%>" target="_blank" title="<%%VALUE(AttachmentFile)%%>" class="btn btn-default"><i class="glyphicon glyphicon-picture text-info"></i></a></td>
<td id="Attachments-UploadDate-<%%VALUE(AttachmentID)%%>" class="Attachments-UploadDate text-right"><%%SELECT%%><%%VALUE(UploadDate)%%><%%ENDSELECT%%></td>
Re: change path to attachment files
sorry i forget some code
should make change in link.php
should make change in link.php
Code: Select all
// upload paths
$p=array(
'Profile' => array(
'Attachments' => array(
//'AttachmentFile' => $Translation['ImageFolder'],
'AttachmentFile' => './Attachments/' . $profileNo . '/',
'primary key' => 'AttachmentID'
),
//'Photo' => $Translation['ImageFolder'],
'Photo' => './Attachments/Profile/',
'primary key' => 'ProfileNo'
)
);
Re: change path to attachment files
Hi everyone,
I have been using the above code ( $Translation['ImageFolder'] = './Attachments/' . $_REQUEST['my_field1'] . "/" . $_REQUEST['my_field2'] . "/" ; ) for a long time, after the new version of AppGini 5.93. in which there was a change in settings ( Move the setting of the file upload path to the admin settings page, making it more convenient to change. ) the code no longer works.
I have tried on several variants to get it to work but to no avail. Does anyone know what would be the correct way to dynamically change the upload folder path with the new version of AppGini (from 5.93).
Thanks.
I have been using the above code ( $Translation['ImageFolder'] = './Attachments/' . $_REQUEST['my_field1'] . "/" . $_REQUEST['my_field2'] . "/" ; ) for a long time, after the new version of AppGini 5.93. in which there was a change in settings ( Move the setting of the file upload path to the admin settings page, making it more convenient to change. ) the code no longer works.
I have tried on several variants to get it to work but to no avail. Does anyone know what would be the correct way to dynamically change the upload folder path with the new version of AppGini (from 5.93).
Thanks.
Re: change path to attachment files
Did you ever figure this out?
TD
TD
Re: change path to attachment files
Check out the things I tried in this post viewtopic.php?f=2&t=4445
Re: change path to attachment files
Hi,
@scarvalh: You should probably not use a field like the name as placeholder for your path. The name might change which will lead to additional work for you. Probably it's better to use the ID as xbox2007 suggested.
@tomislav: I like the idea to change the path in the way you suggested. Maybe it does not work anymore because the language file with this variable is read - but the fields are not available at this time? Maybe it will work again, if you redefine the variable right before you need the path to save your files. But ... thinking about it, the translation file will probably be read in an AG generated file that handles the upload (can not remember where this is). So I want to suggest the following:
- Open the translation file
- Before the translation variable/array starts, make sure, you read the fields that you want to use in the current process.
- change the current translation of $Translation['ImageFolder'] accordingly in the end of the file by adding some code
Pseudo code:
Just an idea
Olaf
@scarvalh: You should probably not use a field like the name as placeholder for your path. The name might change which will lead to additional work for you. Probably it's better to use the ID as xbox2007 suggested.
@tomislav: I like the idea to change the path in the way you suggested. Maybe it does not work anymore because the language file with this variable is read - but the fields are not available at this time? Maybe it will work again, if you redefine the variable right before you need the path to save your files. But ... thinking about it, the translation file will probably be read in an AG generated file that handles the upload (can not remember where this is). So I want to suggest the following:
- Open the translation file
- Before the translation variable/array starts, make sure, you read the fields that you want to use in the current process.
- change the current translation of $Translation['ImageFolder'] accordingly in the end of the file by adding some code
Pseudo code:
Code: Select all
$Translation[.....]
// end of file
//new code starts here
unset ($_SESSION['img_folder_field1']);
unset ($_SESSION['img_folder_field2']);
// I use SESSION vars so that you can still access them from any file - in case you need to reuse them
// also (and maybe more important):
// if you want to hand over some specific value to img_folder_field1 and/or img_folder_field2,
// you can save those in a session var and access this directly here. without querying the database
$sql_field1="SELECT somefield FROM sometable"
$_SESSION['img_folder_field1'] = sqlValue($sql_field1);
$sql_field2="SELECT someotherfield FROM someothertable"
$_SESSION['img_folder_field2'] = sqlValue($sql_field2);
// now we overwrite the "old" $Translation['ImageFolder'] from the start if the language file with the new
$Translation['ImageFolder'] = './Attachments/' . $_SESSION['img_folder_field1'] . "/" . $_SESSION['img_folder_field2'] . "/" ;
Olaf
Some postings I was involved, you might find useful:
SingleEdit - Prevent concurrent edits on records; Field Permissions; Column-Value-Based-Permissions; Custom (error) message; Audit Log; Backup your database; Two Factor Authentication; Block brute force (failed) logins; Add 2nd SAVE CHANGES button; Place a search on details view
SingleEdit - Prevent concurrent edits on records; Field Permissions; Column-Value-Based-Permissions; Custom (error) message; Audit Log; Backup your database; Two Factor Authentication; Block brute force (failed) logins; Add 2nd SAVE CHANGES button; Place a search on details view