Solved

Attaching files to a Sharepoint Library

Posted on 2010-08-23
4
584 Views
Last Modified: 2012-06-22
Is there any way of attaching additional files to a document library in sharepoint.  I have looked at various approaches, including attaching the file to an InfoPath Form that is the basis for the library, but it's a bit wooden.  I just want to make sure I am not missing an obvious solution.
0
Comment
Question by:RichShare
  • 2
4 Comments
 
LVL 53

Expert Comment

by:Will Szymkowski
ID: 33501124
If you want to attach multiple files at one time there is 3 ways of doing this...

1st - You can use SharePoint Designer to accomplish this, Navigate to your document library and upload your files (SharePoint Designer has a maximum of 50MB per transfer)

2nd - Open your document library in Sharepoint and click Upload drop down (upload multiple documents)

3rd - Easiest way to do this is via Windows Explorer, Navigate to your sharepoint document library Under Actions, click click "Open with Windows Explorer"

Hope this helps~!
0
 

Author Comment

by:RichShare
ID: 33501398
Thank you for the prompt response.  What I meant was once the document/item is in the library I want to attach additional supporting files (e.g. pdf, etc.) to support that one library item.  I understand this is possible with a list but the concept of a template library really works for what we want to do but because we require additional signatures we have to scan a signed copy of the document back in to the library/list.  Hope that makes sense?
0
 
LVL 2

Accepted Solution

by:
ibliskavka earned 125 total points
ID: 33510155
Wow, looking back at all this text I guess it was worth first asking if you were interested in a code example...
_____

What I am suggesting will require code. It is not terribly difficult to implement if you have access to a programmer or can do it yourself.

Attaching a file to the form is a great idea but in our case, versioning bloated the library excessively.

Our users attach a file directly to the form, on submit the file data field is passed to a webservice as a string parameter. The webservice decodes the file and saves it to a separate Quotes document library. The webservice then returns a link to that attachment as a return value. Upon receiving the link, the form adds the link to a repeating table of attachments links and clears the form's attachment field. Then the form is submitted to the document library.

This allows us to use as many attachments as we want without actually storing the files in the form which helps with opening time and our storage requirements.

The class for decoding/encoding infopath attachments is located at:
http://support.microsoft.com/kb/892730

There is a bunch implementation examples on the web for it. I attached my WS function below.
This is a simplified function, the return value should probably be encoded as a HTML link before saving it to a rich text link field.
private static string UploadAttachment(
string attachmentString, string fileName, string checkInComment)
{
   InfoPathAttachmentDecoder decoder =
      new InfoPathAttachmentDecoder(attachmentString);

   string[] filearr = decoder.Filename.Split('.');
   string fullFileName =
      fileName + "." + filearr[filearr.Length-1];

   using (SPSite objSite = new SPSite("http://mysite"))
   {
      SPUserToken sysToken = objSite.SystemAccount.UserToken;
      using (SPSite purchSite =
         new SPSite("http://mysite/purchasing", sysToken))

      using (SPWeb objWeb = purchSite.OpenWeb())
         {
            SPFolder myLibrary = objWeb.Folders["Quotes"];
            objWeb.AllowUnsafeUpdates = true;

            myLibrary.Files.Add(fullFileName,
               decoder.DecodedAttachment,
               true,
               checkInComment,
               false);
         }
      }
   return fullFileName;
}

Open in new window

0
 

Author Closing Comment

by:RichShare
ID: 33702721
Thank you
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Last week I faced a strange issue recently, i have deployed SharePoint 2003 servers for one project and one of the requirements was to open SharePoint site from same server. when i was trying to open site from the same server i was getting authentic…
For SharePoint sites, particularly public-facing ones, there are times when adding JavaScript, Meta Tags, CSS Styles or other content to the page <head> section is more practical than modifying master pages.  For instance, you could add the jQuery l…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question