Form Attachment
Permalink 3 users found helpfulmessage goes in (reports > form results)
file goes in (file manager >Display files in no sets.)
Is it possible to change the folder in which the attachments upload into while still being able to view them in the file manager?
I need to password protect the folder in which the files get uploaded from the form. Otherwise any files sent via the form are susceptible to being viewed by the world.
If this is too much of a task, is it possible to have the form just email the form data out to an email address instead of using the dashboard? I could set an SSL SMTP address in the dashboard and tell the form block to use that instead of uploading into the dashboard.
Any thoughts on this?
Copy the form block from /concrete/blocks to /blocks
Edit /blocks/form/controller.php
Change this:
$tmpFileIds[intval($row['msqID'])] = $resp->getFileID();
to
$tmpFileIds[intval($row['msqID'])] = $resp->getFileID(); Loader::model('file_set'); $fs = FileSet::getByName('uploads'); $fsf = $fs->addFileToSet($resp);
This assumes that you have a file set created already named 'uploads'
To change the form to allow an admin to pick the fileset would require and additional database field for this block to store the fileset ID.
First, as above, copy the /concrete/blocks/form/controller.php to /blocks/form/controller.php
Modify this line
$tmpFileIds[intval($row['msqID'])] = $resp->getFileID();
to
$tmpFileIds[intval($row['msqID'])] = $resp->getFileID(); Loader::model('file_set'); $page = Page::getCurrentPage(); if (!$page->getCollectionAttributeValue('form_fileset')){ $fs = FileSet::getByID(0); }else{ $formset = $page->getCollectionAttributeValue('form_fileset'); if (!FileSet::getByName($formset)){ $fs = FileSet::createAndGetSet($formset, FileSet::TYPE_PUBLIC, $uID = false); }else{ $fs = FileSet::getByName($formset); } } $fsf = $fs->addFileToSet($resp);
Then, create a new custom attribute of type text called Form File Set with the handle form_fileset
Now on the page with the form, add this new attribute and type a file set name in the field (must be exactly the fileset name - case sensitive) otherwise it will create a new fileset with the attribute name and put the file into that instead.
If the attribute is absent from the page, it will place the file into no sets.
This has been roughly tested so let me know if you have any problems.
EDIT: replaced TYPE_PUBLIC with FileSet::TYPE_PUBLIC
In the action_submit_form() function:
//try importing the file if everything else went ok $tmpFileIds=array(); if(!count($errors)) foreach($rows as $row){ $questionName='Question'.$row['msqID']; // Get the value of the select control to indicate the file set to add the uploaded file to. if( $row['inputType']=='select' ) $fileset=$txt->sanitize($_POST['Question'.$row['msqID']]);
...and then a little further down in the same function...
It's kind of a heavy-handed approach, and because I overrode the form block then it will affect every form I add to the site. If I wanted to be thorough I'd go through and rename everything to a new version of the form block and call it UploadFileSetForm or something. I'll probably end up doing that eventually but I don't have the energy right now.
Hope this helps someone!
1) I declared the $fileset variable as a public attribute at the class level. This was while I was dinking around trying to make things work - you could as easily declare it locally in the action_submit_form() function.
2) The $questionName assignment is superfluous. I don't use it for anything. That's in there as a remnant of me trying to identify the select control by name. I will probably keep trying to make that work so I can have multiple selects on the form and pull the value from the correct one, but it's not used in the code I quoted above.
3) The die(_("No file set selected.") is a debugging statement. You should probably take that out.
http://landsmachining.net/files......./112448_nature.jpg...
How do I use the form and make the file hidden from other web viewers? Perhaps SSL is the key on the entire domain or would that just secure the form transmission of data to the email recipient and the dashboard?
regards,
Now on the page with the form, add this new attribute and type a file set name in the field (must be exactly the fileset name - case sensitive) otherwise it will create a new fileset with the attribute name and put the file into that instead.
I have done everything else but I am not sure how to do this.
define('PERMISSIONS_MODEL', 'advanced');
This should give you the ability to set permissions on sets.
Fatal error: Uncaught exception 'Exception' with message 'Oops, something is wrong with the form you posted (it doesn't have a question set id).' in /home2/sosweene/public_html/landsmachining/blocks/form/controller.php:204 Stack trace: #0 /home2/sosweene/public_html/landsmachining/concrete/models/block.php(276): FormBlockController->action_submit_form() #1 /home2/sosweene/public_html/landsmachining/concrete/startup/process.php(214): Block->passThruBlock(Array, Array) #2 /home2/sosweene/public_html/landsmachining/concrete/dispatcher.php(226): require('/home2/sosweene...') #3 /home2/sosweene/public_html/landsmachining/index.php(2): require('/home2/sosweene...') #4 {main} thrown in /home2/sosweene/public_html/landsmachining/blocks/form/controller.php on line 204
The advanced permissions code should be put at the end (it really doesn't matter) but before the closing ?>
Under file manager > sets > uploads > edit
I am checking the new box that appeared which is labeled 'Enable custom permissions for this file set.'
When I click update on the bottom and then go back in to edit mode, the check-box is not checked. Do you happen to know if I did something wrong here?
There is only two people that have access to the dashboard. I can still see the uploaded file that is in this set after implementing the code and setting the permissions.
http://landsmachining.net/files/2112/8078/7475/112448_nature.jpg...
I do need to see if there is a way to restrict access to these files if possible.
Do you have any suggestions?
If you do than this would be an all around big help to me and all of the community as you have created a way to resolve these issues.
Please note that I'm also creating a file set directly from the forms name without looking for a custom page attribute.
Loader::model('file_set'); /** @var TextHelper $th */ $th = Loader::helper('text'); $filesetName = $th->camelcase($this->surveyName) . "Uploads"; /** @var FileSet $fileSet */ $fileSet = FileSet::getByName($filesetName); if (!$fileSet) { $fileSet = FileSet::createAndGetSet($filesetName, FileSet::TYPE_PUBLIC); $fileSet->Save(); // FileSet isn't being saved... } $fileSet->addFileToSet($resp);
Cheers
Andrew
can anyone be able to help me??
as I say I am a complete novice so if anyone could show me where i go to do it too I would be very grateful.
Robert
best wishes
Franz Maruna
CEO - concrete5.org
http://about.me/frz
fans will have to register for my site and then they will get access to see my site...so it will be just for registered users of my site.
what I am wanting is when a fan clicks on a particular fixture it will take them to that fixtures page and on that page will be a file upload form and an image gallery...and when a fan then uploads a picture through the form I want it just to go in the the image gallery that is on that page.
I want to have the same thing for all the other fixtures....so I will need to have a lot of galleries one for each fixture and to have an individual upload form linked to each one.
so I am wondering how I can link the form/multiple upload form to the gallery.
hope that make more sense for you.
Robert
Robert
Until then, I'm afraid the only way I can think of doing this involves some coding.
Robert
are you sure that someone has a request to extend the form block?? is there any way of checking?
thanks
Robert
-J