I'm using AppGini 5.62
I have table field for pdf file type only, upload. would like to restrict download links to Admins and Officers only.
Can this be done with hook code, where and how would help.
Thanks..
File download restriction.
File download restriction.
What we envision, we make happen.
- baudwalker
- Veteran Member
- Posts: 188
- Joined: 2015-02-03 08:08
- Location: Bellingen NSW Australia
Re: File download restriction.
I too would like the upload of a PDF only. With the lack of response it does not look too hopeful
Re: File download restriction.
Jay, you go to the page hook file.
Look for the 'init' function in the hook file, The code below is an example to restrict download to certain users.
function XXXXXXXXXXX_init(&$options, $memberInfo, &$args){
$csvusers = array("123456789", "uk", "europe");
if(in_array($memberInfo['username'], $csvusers)){
$options->AllowCSV=1;
}else{
$options->AllowCSV=0;
}
return TRUE;
You can change the 'username' to one of the other variables like groups etc. to see what is available, take a look here - If you look at the member array here - http://bigprof.com/appgini/help/advance ... memberInfo
Look for the 'init' function in the hook file, The code below is an example to restrict download to certain users.
function XXXXXXXXXXX_init(&$options, $memberInfo, &$args){
$csvusers = array("123456789", "uk", "europe");
if(in_array($memberInfo['username'], $csvusers)){
$options->AllowCSV=1;
}else{
$options->AllowCSV=0;
}
return TRUE;
You can change the 'username' to one of the other variables like groups etc. to see what is available, take a look here - If you look at the member array here - http://bigprof.com/appgini/help/advance ... memberInfo
Re: File download restriction.
baudwalker - to allow PDF ONLY upload, you can do one of two things:
1. To generate the code to restrict uploads of PDF only through AppGini itself; edit the \appgini\add-ons\fileTypes.cfg file. Add a new line in the cfg file under existing lines with just the file type pdf. You'll then see the PDF option in the dropdown of filetypes - see the screenshot below from the AppGini help screen that relates (click the "Configure" button then the red Danger link on the Media tab to get to this screen). You'll need a text editor to open the fileTypes.cfg file - Notepad++ is a good choice if you're looking for one
2. Edit the generated yourtablename_dml.php file. You'll have to search through and find all lines that relate to "PrepareUploadedFile" and edit the allowed file type to just PDF for the particular fields you want to limit. You'll probably see the default files types of: txt|doc|docx|docm|odt|pdf|rtf Just edit those files types to 'pdf' Now Users will receive an error if they try to upload anything other than a PDF.
1. To generate the code to restrict uploads of PDF only through AppGini itself; edit the \appgini\add-ons\fileTypes.cfg file. Add a new line in the cfg file under existing lines with just the file type pdf. You'll then see the PDF option in the dropdown of filetypes - see the screenshot below from the AppGini help screen that relates (click the "Configure" button then the red Danger link on the Media tab to get to this screen). You'll need a text editor to open the fileTypes.cfg file - Notepad++ is a good choice if you're looking for one
2. Edit the generated yourtablename_dml.php file. You'll have to search through and find all lines that relate to "PrepareUploadedFile" and edit the allowed file type to just PDF for the particular fields you want to limit. You'll probably see the default files types of: txt|doc|docx|docm|odt|pdf|rtf Just edit those files types to 'pdf' Now Users will receive an error if they try to upload anything other than a PDF.
- baudwalker
- Veteran Member
- Posts: 188
- Joined: 2015-02-03 08:08
- Location: Bellingen NSW Australia
Re: File download restriction.
Thank you. nearly as simple as me