Solved

Attaching files to a Sharepoint Library

Posted on 2010-08-23
4
559 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

I recently came across an issue with a MOSS 2007 deployment where access into some sub-sites were denied, even for the MOSS farm administrators. A bit of background to the setup of this MOSS farm; this was a three server setup, consisting of a fr…
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…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

746 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now