logo

Attachments Manager R1.0

You may have noticed that, recently, I have published a couple of articles talking about how to work around the fact that the vanilla look of attachments on the web is like this:

Image

The first article demonstrates how to hide the attachments from the browser. The second article then showed a way to produce an alternative to deleting them.

So what it this going to be about then? Well, it is a database for you to download that demonstrates both methods in action. You can download it using the link in the column on the left or by clicking on its screenshot below:

Image

Send me any feedback you can come up with and watch the version number of the database go up. As well as getting your name on this page. Wow....


Feedback

  1. Thank you! Thank you! Thank you!

    I've incorporated all three sections into one for convenience (add, delete, view), but I wouldn't have even known where to start without you! Thanks a ton for putting in the time to publish for those of us new to the platform!

    1. No. Thank you!

      I like to think that, recently, CodeStore has begun to take the shape I intended of it and is fill the gap in sites that offer "useful" Domino related design ideas.

      I would not be so sure of this or so willing to continue if weren't for the people, such as yourself, confirming this for me.

      Thank you and please return as often as you like, Jake

  2. Corrupt Date Exceptions on Web File Attachments

    I have implemented your AM v1.0 tips and design in a document mgt repository. This of course works perfectly but I am experiencing some server-side issues definitely unrelated to this design. When users edit some of the documents (attachment postings) and try to access again from the view they get "The page cannot be displayed" returns and server-side the Notes Log notes the error "HTTP Web Server: Corrupt Data Exception [/Project+Management/Next2DocRepos.nsf/ByDocId/2BCD5782C613828C88256A9300800FD0? OpenDocument&030528]". This occurs on multiple documents and not always reproducable, especially for me (testing a solution? forget it!). I have research numerous forums suggesting the problem lies with pass-thru HTML, indexing, etc. I have rebuilt the deviant form. All to no avail. I am running R4.6 leveraging lots of native HTML/JS on this form. Did you have such issues in your design; any solutions based upon your experiences?

    Cheers!

    1. Re: Corrupt Date Exceptions on Web File Attachments

      Hi,

      Sounds strange. The only time I have seen this error it has been something to do with the user opening a document in edit mode, the design changes in the background and THEN the user submits the document. Could that be it?

      Otherwise, I have no idea. Mail me the app if you want and I can try taking a look.... either way, if you find out the problem don't forget to [<a href="area/54159BBCA099B4A0862569990055A9DA?OpenDocument">log it here</a>]

      Jake -CodeStore

    2. Watch Pass-thru HTML before and after File Upload

      It appears that the warnings about pass-thru HTML were valid. I had to "surround" the File Upload Control with native Notes text, i.e. no pass-thru HTML (defined by style or [], it didn't matter) before or after the FUC on the form.

      Now this may be a R4.6x bug fixed in R5 so maybe that is why you did not experience in your design. Just a word of warning to those still mired in version stagnation!

    3. Re: Problem with recalculating computed fields

      I have implemented almost similar solution like Attachments Manager in my application. I have one fileuploadcontrol in my form. I am using '_RefreshKW' to recalculate the computed fields. When I select a file to upload and recalculating the computed fieds, the file is not getting uploaded because the value in the FUC is disappearing while recalculating computed fields. Is there a work around to retain the FUC value even after recalculation?

      Many thanks.

  3. Question about the /str/

    Hi:

    Great work with the Attachments Manager. It's a very good Idea. I just write to make a question: when you Re-open the document with the new attachments throught the $$Return Field ... you do it with this code: "[/" +DBPath + "/str/" + @Text(@DocumentUniqueID) + "?EditDocument]"

    I don't understand the meaning of "/str/" in this code, but it doesn't work if i take it off. Could somebody tell me what's it's use?

    Thanks a lot, and keep up the good work. Gretings from Spain.

    1. Re: Question about the /str/

      The "str" is an alias for the "Stores" view in the database and its needed to find the document.

      Hope this helps...

  4. Error if Spaces & Chars in Filenames

    If your author uploads a file that contains any spaces or special characters, later when the document is read and you click on the link to download or open the file, you'll get the error "HTTP Web Server: Item Not Found Exception". (All of my Domino dbs are developed for the web.)

    For example, if you create a new document (or edit an existing one) and upload the file "Case Study - Baxter Hea#AC8.doc", later when you click on the link to open the uploaded file, Domino will attempt to open the file "Case%20Study%20-%20Baxter%20Hea#AC8.doc" thus generating the error.

    I found that I had to add a warning to my authors to not include any spaces or special characters when uploading files.

    Was curious if anyone found a solution that would still allow authors to have spaces or special characters in filenames since it's common in the Windows environment??

    BTW, thanks so much for Codestore.org! It has helped me a great deal in developing Domino dbs for the web!!

    1. Re: Error if Spaces & Chars in Filenames

      I haven't tried the Attachment Manager yet, but the reason for what seem to be broken links is pretty simple. It's a result of encoding ASCII Text to ISO Latin character set that is necessary to pass anything containing spaces and other special characters as arguments in an URL.

      If your only problem ist the appearance of %20 instead of a blank, simply include the following formula into the portion of code where the links are created:

      @ReplaceSubstring(input; "%20"; " ")

      The encoding is usualy done in JavaScript using the top level function escape(). The complementary function is called unescape().

      If using @ReplaceSubstring of unescape() is suited better to solve your problem depends mainly on how the original encoding was done.

      As I said, I didn't have a look at the code yet, but for sure I will change that right now. Originally I had planned to write somethin similar jus today ... luckily I didn't start before checking the codestore ... ;-)

  5. use true icons

    Very nice.

    As an optional addition you can store icons of the most common document formats that you can display instead of the paperclip. I did this creating small icons:

    Create icons: - open windows explorer - go to a folder with different document types - do View > List - press PrntScrn - open an image editor (like Paint) - convert the icons to JPGs - save them as PDF.JPG, DOC. JPG, XLS.JPG etc

    - import them as Image Resources in the database

    - in the multi value computed for display text field with seperator 'New Line put the formula:

    DB:=@ReplaceSubstring(@ReplaceSubstring(@Subset(@DbName; -1);" ";"+");"\\";"/"); AN:=@AttachmentNames; @If(!@Attachments; @Return(""); ""); "<a href=/$File/" + AN + "><IMG SRC=/"+DB+"/"+@Right(AN;3) +".jpg?OpenImageResource border=\"0\" >" +AN + "</a>" off course, insert scare brackets before and after HTML code.

    1. Re: use true icons

      That's what I like to see. Not only somebody showing a little intuition but also the willingness to share. A man after my own heart ;-)

      The only thing I would say is that you are better off saving them as .gif files rather then .jpg.

      Jake -codestore

    • avatar
    • dan
    • Tue 19 Feb 2002

    Attachments as thumbnails

    Your article was very helpful.

    To view them as thumbnails, the following seems to work both in computed text fields and view columns.

    for view columns I used one column per attachment (the only way I could get it not to fail with non-gif/jpg files), with a sequential number 1 through however many you want to show.

    I started with the formula from the Roundtable application http://roundtableweb.com (freeware version).

    For the form, I made the non-gif/jpg's null, together with the stuff from this article.

    Seems to work so far. . .

    --Dan

    SelectedFile:=@Word(@Implode(@AttachmentNames); " ";SEQUENTIALNUMBERHERE); ANames:=@ReplaceSubstring(SelectedFile;" ";"+"); ANames2:=@ReplaceSubstring(SelectedFile;" ";"_"); DBName := @ReplaceSubstring(@ReplaceSubstring(@Subset(@DbName; -1);" ";"+");"\\";"/"); open:="?OpenElement"; view:=@ReplaceSubstring(@ReplaceSubstring(@Subset(@ViewTitle; 1);" ";"+");"\\";"/"); docid:=@Text(@DocumentUniqueID); url:="[<a href=/"+dbname+"/"+view+"/"+docid+"/$FILE/"+ANames+"><img src=/"+dbname+"/"+view+"/"+docid+"/$FILE/"+ANames+" WIDTH=100 HEIGHT=66 border=2 ALT="+ANames2+"></a>]"; url2:="[<a href=/"+dbname+"/"+view+"/"+docid+"/$FILE/"+ANames+"><img src=/icons/vwicn005.gif border=0 ALT="+ANames2+"></a>]"; @If(SelectedFile = NULL;NULL; @Ends (@LowerCase(SelectedFile) ; "gif" ) ; url; @Ends (@LowerCase(SelectedFile) ; "jpg" ) ; url; url2)

      • avatar
      • dan
      • Wed 20 Feb 2002

      Re: Attachments as thumbnails

      whoops, try this delete *. Is there an easier way to do that?

      SelectedFile:=@Word(@Implode(@AttachmentNames); " ";1); ANames:=@ReplaceSubstring(SelectedFile;" ";"+"); ANames2:=@ReplaceSubstring(SelectedFile;" ";"_"); DBName := @ReplaceSubstring(@ReplaceSubstring(@Subset(@DbName; -1);" ";"+");"\\";"/"); open:="?OpenElement"; view:=@ReplaceSubstring(@ReplaceSubstring(@Subset(@ViewTitle; 1);" ";"+");"\\";"/"); docid:=@Text(@DocumentUniqueID); url:="*[*<*a href=*/*"+dbname+"/"+view+"/"+docid+"/$FILE/"+ANames+"><img src=/"+dbname+"/"+view+"/"+docid+"/$FILE/"+ANames+" WIDTH=100 HEIGHT=66 border=2 ALT="+ANames2+"></a>]"; url2:="*[*<*a href=/"+dbname+"/"+view+"/"+docid+"/$FILE/"+ANames+"><img src=/icons/vwicn005.gif border=0 ALT="+ANames2+"><*/*a*>]"; @If(SelectedFile = NULL;NULL; @Ends (@LowerCase(SelectedFile) ; "gif" ) ; url; @Ends (@LowerCase(SelectedFile) ; "jpg" ) ; url; url2)

  6. Nice... I've been looking for this a long time

    This site it worth it's weight in gold! This works perfectly on my site, and makes my users very happy and satisfied.

    1. Re: Nice... I've been looking for this a long time

      Thank you. Nice words always well received over here ;-)

      I know it's only a metaphor but you got me thinking exactly how much does this site weigh?

      Does the density of the HDD change as it receives more data? I have no idea! Not much gold though ;-)

      Must go to bed. Need sleep....

      Jake

  7. Deleting my body

    I love all of the goodies in here!!!

    However, I'm having trouble with building an array of fields to validate.

    I only have two fields. But If I use your method, my body gets deleted when saved.

    I tried: a[a.length] = [f.PageName, 'Page Name']; a[a.length] = [f.NavOrder, 'Navigator Order Number'];

    I must have left off something....

    Thoughts?

    Scott

    1. Re: Deleting my body

      Whatever it is you mean by "body" and it being "deleted" I am pretty sure it has nothing to do with the JS validation.

      Jake -codestore

      Show the rest of this thread

  8. Need Flexible security on $file attachments (web)

    I am looking for some creative ideas or tricks.

    I would like to hide (and truly secure) file attachments on a web form. Some users should see the link and be able to access/download the file. While others should not.

    Using roles and the "$V2AttachmentOptions" field, I am able to "Hide" the attachments from certain roles/users on the web. However if the file name is known, it can still be accessed. (Hence, not secure)

    Notes Doc ID/$file/file attachment name.doc

    Any ideas ? Suggestions ? Remember web access, and I also have a fair amount of existing documents & attachments in the application.

      • avatar
      • jc perrin
      • Tue 8 Oct 2002

      Re: Need Flexible security on $file attachments (web)

      There's a very very very interesting db on the iris sandbox which gives an idea to solve this problem (if fact, it saved my life! ;-):

      Alan Hurt, DHTML Rich Text Editor v4b

      http://www-10.lotus.com/ldd/sandbox.nsf/ecc552f1ab6e46e4852568a90055c4cd/0ecbfc8 0064383e600256bd8003a835e?OpenDocument

      Look at the Attachment form: each attachment is stored in a different document, which makes you free to use readers fields (The main doc only keeps the URL of the attachment)

    • avatar
    • Paul
    • Thu 25 Jul 2002

    Well, you should check this out!

    I came across this site recently. Pretty cool tool. http://www.dlitools.com

    • avatar
    • Dan
    • Tue 10 Sep 2002

    Limited number of documents in view on web?

    Nice app! One problem though...after adding new documents to the db, I am not able to see any documents past the 30 mark via the web. If I add a document and refresh in Notes, I see it added...however I do not see it when viewing thru a browser. Any way I can change this? Am not seeing where this is set...! Thanks much!

      • avatar
      • Jake
      • Tue 10 Sep 2002

      Re: Limited number of documents in view on web?

      You need to use the &count= parameter.

      By default web views show 30 documents (can be changed in the server document) but you can show more by appending &count=50, or whatever, to the URL.

      You can also use &start=30 in a link to go to a page showing the 30 documents after the ones you're currently looking at.

      Jake -webmaster

      Show the rest of this thread

  9. Attachment Extensions truncated

    I had a strange problem here. I am using the attachment manager functionality. If a n user is using a Japanese windows OS and then attempts to upload a file, the file extension gets truncated to 2 characters, i.e if he uploads .ppt the attachment is saved as .pp

    Has anyone seen this before? Maybe a domino bug itself or maybe something related to the Attachment Manager, don't know, haven't found much info about this either at notes or at microsoft.

  10. attachment

    Hi,

    is there a possibility to limit the file size of attachments?

    Thank you, Birgit

    1. Re: attachment

      Yes, Jake has function code in the .JS page that at that checks for file size. Great code! Thanks....s

  11. Woaw ! its's great, thank you !

    • avatar
    • Lisa
    • Sun 28 Sep 2003

    Attachement with Java applect RTF

    After some testing, I found that it works great if there is no RTF field(s) with Display with Java applet for Web access in the form. The field simply doesn't display on the web. Do you have a way to achieve the same result if there is such a RTF?

    Thanks.

  12. HOLY ANSWER, BATMAN!

    I'm starting this web project where they want up to three (and no more than three) attachments in their documents, and I'm realizing that's going to be a little complicated when people can re-edit documents again and again. Surely someone's done this before....

    So I google for "+domino +attachments +web" and guess who comes up first?

    And it's useful!

    So, once again, thanks. You da man.

  13. Refreshing the form

    OK, blast from the past. Jake, I really dig this tool, use it a lot and am eternally gratefull. Honest!

    Anyway, I ran into a snag that I can't seem to solve, blind spot I guess.

    I need to refresh the doc without using the $$return field. I have so much Javascript in the saving and closing of the doc to get back to exactly where I was before I started editing that I can't use the $$return.

    So how do I "refresh" the doc, i.e. save it and display it again, using javascript, without the normal submit? Right now I am using @Command(FileSave) but I am missing validation on two fields and since it is a new doc, no way to check them using @formula's. Ideally I would like to validate in JS and then call @Command(FileSave) but how?

    • avatar
    • chris
    • Thu 28 Oct 2004

    !! do not function with firefox !!

    buttons does not function with firefox!

    because, it misses the type of the button.

    ex: in defaultview: -------------------------------------------------- <button accessKey="n" onclick="location = 'store?OpenForm';"><img src="/icons/vwicn012.gif"> <u>N</u>ew</button> -------------------------------------------------- but -------------------------------------------------- <button accessKey="n" type="button" onclick="location = 'store?OpenForm';"><img src="/icons/vwicn012.gif"> <u>N</u>ew</button> --------------------------------------------------

    regards

    ps: sorry, but i'm french lol

    • avatar
    • Lois
    • Fri 18 Feb 2005

    Attachment

    I used your code for attachments and it works great. My users want to be able to add a description for each attachment. If anyone has code to do this I would love to see it.

      • avatar
      • Olly
      • Mon 4 Apr 2005

      Asking the impossible.....

      Great template!

      However it *seems* to remove the progress bar in IE (6.0.28).

      I have looked all over the web for this kind of functionality but is there anyway to include the ability to see the progress of the file upload? I know the document is active during the upload(?) and the post data contains the size and filename so surely it could also write the amount of data transferred, or does this need to be a CGI app?...

      Any ideas???

  14. Multiple file attachments through one FUC.

    I wonder about the multiple file uploading through a single "Browse"(File Upload button). Is it possible in Microsoft Internet Explorer, Lotus Notes Preview and Lotus Notes Browser Preview? We are looking forward for your quick reply. Thanking you.

  15. where is sample the database

    It's just what I am looking for now:)

    1. Re: File Upload in two different fields

      I have two File Upload Controls on my form and would like the attachments saved in two different fields instead of one RTF (Attachment) field, how can I achieve that?

      Any ideas?

      Thank You.

      Show the rest of this thread

    • avatar
    • Patrick
    • Tue 2 Sep 2008

    file upload works great

Your Comments

Name:
E-mail:
(optional)
Website:
(optional)
Comment:



Navigate other articles in the category "Miscellaneous"

« Previous Article Next Article »
Hiding attachments (without noscript tag!)   Exam 190-513: Using JavaScript in Domino R5 Applications

About This Article

Author: Jake Howlett
Category: Miscellaneous
Keywords: file; attachment; noscript; remove; delete; upload;

Attachments

Attach1.zip (33 Kbytes)

Options

Feedback
Print Friendly

Let's Get Social


About This Website

CodeStore is all about web development. Concentrating on Lotus Domino, ASP.NET, Flex, SharePoint and all things internet.

Your host is Jake Howlett who runs his own web development company called Rockall Design and is always on the lookout for new and interesting work to do.

You can find me on Twitter and on Linked In.

Read more about this site »