File attachment from HTML form doesn't get replaced on Domino server - file-upload

I have a Domino database that stores documents with file attachments. The file attachments are stored in the Body RichTextItem as attachments.
For managing these documents I have an HTML form containing a file upload field.
Now, when I upload a file whose name differs from the current file in the document, everything works fine, and the uploaded attachment replaces the previous attachment.
The problem is when I upload a file that has the same name as the already existing file. In the WebQuerySave property of the form I call a LotusScript agent that should replace the old attachment with the one from the HTML form.
But in this agent I see two items called $FILE that have the same FileName. When I access them, I cannot distinguish these two items. I tried:
document.GetAttachment(filename) – obviously doesn't work, since the names are the same => I can only access the first attachment.
ForAll item in document.Items – I visit two items having the name $FILE, but both items are the same: the modification time is the same, the filesize is the same.
I could get all the attachments and remove all of them but the last. But is there any guarantee that the last item is the one from the HTML form? Or I could first extract the modification time from all the attachments and remember the newest. That must be the attachment from the HTML form.
Or is there a simpler solution?

For reasons like this behavior and several others, I have built most of the basic web facing Domino applications to store attachments on linked documents instead of the primary document. That way they can be accessed easily and do not get updated or modified except when they are supposed to be.

Related

Where best to store a version number in Word document?

I have a VSTO Add-In that fills a specific Word template document with data from a third party software. The trick here is that some changes in the script are connected to changes in the document. What I want to do now is to manually store some kind of version number in the document information so I can check in the script if the version of the document fits the version of the script.
I already took a look here but there are too many possibilities and I don't just want to pick any random object. I need to store it somewhere where it doesn't get changed.
Where would you recommend to store such a value?
edit: the version number has to be set manually because not every change of the document affects the script.
You have three options:
Document property - can be displayed in a document by using a DocProperty field but can be viewed and easily changed by the user.
Document variable - an old school method but still valid. Can be displayed in a document by using a DocVariable field but can only be added, or the value changed, by using code.
Custom XML Part - can be displayed in a document by mapping to a content control which can allow the value to be changed by the user. If not mapped can only be changed using code, but not as simply as a document variable.

Is there a way to generated several PDFs from a loop and store them without saving the files to disk?

I am trying generate several individual pdfs from html in a group of elements within a node on a webpage with jsPDF. (Report cards for students). Then I need to email the individual report cards to each students parent using JavaMail.
The problem is: I don't want to save the pdf files to disk as they are generated, instead I want to programmatically loop through the report card elements in the page (id="'studentCard_' + studentId", generate the individual pdfs from the html and store or push each individual pdf into an array or object on the fly (as they are created) that I can then pass over to JavaMail and loop through to attach each individual pdf to the associated parents email.
I can convert the html to pdf without a hitch...
I am just not sure as to how to then attach this pdf to the email since the only option is to pdf.save(filename), and I don't want to actually SAVE each individually generated pdf in the loop to disk - I just want to temporarily store the generated file before I attach it to the emails and send it out.
I have converted the pdf to a blob and a blob URL and I am able to then push the blob into an array. Can I just convert the pdf to a blob or blob url and push it to an array and then loop through that array and attach that to the email. Is this my Solution to convert each pdf to a blob, then push the blob to an array to be passed on to JavaMail to loop through?
I don't know anything about this aspect of my problem. If I attach a blob to the email, or insert the blob URL in the body, when the parent clicks on the file to download it, or clicks on the link inserted into the body, will it automatically be converted back to PDF format for them to read by their own mail program or in the browser? How do I do this correctly?
You may use IndexedDB, the client-side storage of the browser. I like JsStore, an IndexedDB wrapper. I have used it for a couple of my projects. It's pretty neat.
pdf.save(filename) is NOT the only option. You should be able to use pdf.output(datauristring) or pdf.output('blob') and save it to IndexedDB. Depends on your pdf file size, you may even use localStorage, which is easier to use but has much less storage than idb.

Moodle PHP filehandeling

My problem is that we have made an block that opens a page witha a mform on it. And we use the editor element to start the tinyMCE editor, on the page. But when we save the output, the images oploaded to the text field is only viewable to the admin (the person who uploaded it) and in the mdl_files it sets it to be a draft file. I have been through the documentation, and i might have lost the context on the new page, but im not sure.
In Moodle, files uploaded to a form (either to a filemanager element or a text editor) are stored in a temporary 'draft' area while the form is being edited.
This is so that the actual files are not changed until the form is submitted (e.g. if an admin changed the image embedded in some text, deleting the original, you do not want anyone viewing the page during the editing to see a broken image link).
When working with files embedded in a text editor in Moodle, you need to make sure you copy all existing files into the 'draft' area before you show the form, then copy the 'draft' images into the real area, after the form is submitted.
See https://docs.moodle.org/dev/Using_the_File_API_in_Moodle_forms#editor for details about how to do this.
Please also note that your plugin will also need a PLUGINTYPE_PLUGINNAME_pluginfile() function in its lib.php, in order to authenticate any file requests from the user's browser and return the file contents. See any of the core activities for examples of this (e.g. mod/data/lib.php - function data_pluginfile()).

Get notified about new filename of saved PDF document from Adobe Reader DC

Based on data from a SQL database, I dynamically create reports as PDF Report, say costs-2015_01.pdf. This document is automatically saved on a pre-configured (application wide) directory, e.g. C:\reports\costs-2015_01.pdf.
The full path (incl. filename) gets stored in a database table called tblDocuments.
After that, I call acroread.exe with the document path as argument to open the report.
The problematic part is, that the document contains two digital signature fields. If the user signs the document, Reader asks automatically after the signature process for a new file location (Save-as Dialog). Most users are saving the new file under a different name and location instead of overriding the origin file, for example 'C:\My Documents...'.
The problem is: from my calling application, I don't get notified about the new path and can not update the file location in my database document table.
The best solution would be to prevent Reader from asking for a new file location, instead save back the report incl. signature to the origin file.
But that seems impossible. So I'm asking if it is possible to get notified by Reader if the document was saved under a new file name/path.
Users always open PDF files from my application, based on path info stored in tblDocuments. If I can't update the path, users always gets the unsigned - original - pdf document because I'm not aware of the new signed pdf.
What you could try, is to use the didSave event (that's one of the Document Actions in the JavaScript tool), where you would submit the path to the database.
How you would do that, depends on your environment.

multiplefile uploader select and show multiple files at once

i want a multiple file uploader (not ajax) for my form.. The features i needed are:
1) ability to select multiple files at once
2) after selection it should display all the filenames (or image) with a button to remove any pic
3) should be able to set number of files limit, file type and file size limit
4) when i submit the form, i should get an array of these files which i can save one by one to a folder and corresponding file names to a database table.
fortunately yii has got the widget 'CMultiFileUpload' which serves almost all my purposes except that when i select multiple files and click open it only shows the first file name with a remove button.. i want it to show all the selected files at once..
Eg: i select 3 files (i can select multiple files by giving 'multiple'=>'multiple' attribute) and click open then it should show
[removebutton]file1
[removebutton]file2
[removebutton]file3
ll the ajax uploaders have all these functionalities but i cant/don't want to use an ajax uploader because, suppose someone uploads many files using ajax uploader and he then decides to cancel the actual form submission, all the files he uploaded will be there in my uploaded folder, which leads to wastage of space and i have only a limited amount of space in my server. is there any way that i can do this using 'CMultiFileUpload' or is there any other way by which i can do all this? Please help
hope this help your answer,the multi upload in yii http://www.yiiframework.com/wiki/176/uploading-multiple-images-with-cmultifileupload/