MOSS Forum

Ask Question   UnAnswered
Home » Forum » MOSS       RSS Feeds

Uploading a document to document libary sub folder programmatically

  Asked By: Felicia    Date: Jan 14    Category: MOSS    Views: 4541

I created a feature to add new dropdown action item, for example,
"Upload from source abc", under Upload menu of a document library. I
was able to upload document library to the root folder of the document
library, not don't know how to upload a document library to the
current folder.

For the action URL, according to the sdk, the following tokens are
available: ~site, ~sitecollection, {itemid}, {ItemUrl}, {ListID},
{SiteUrl} and {RecurrenceId}. {ListId} gives me the document library,
but How can I get the current subfolder?

To help you understand my situation, here is the big picture: I need
to develop the functionality to enable user to browse a source of
documents, such as a document management system(DMS) and upload the
document from the DMS to the current folder of the SharePoint document

I am using MOSS 2007.

Any suggestions?



6 Answers Found

Answer #1    Answered By: Jagdish Joshi     Answered On: Jan 14

You have to enumerate the folders in the library, and then from the folder
object call the add  method to add the file to that folder. That was the way
it was done in 2003 (at least the way I did it :) ) I imagine it will still
work that way, if they haven't improved it and allowed you to add the file
to a folder  directly.

When I implemented it I basically parsed the folder path where I wanted the
file to be uploaded to, and checked that each leaf of the folder existed, if
it didn't I'd create it and continue from there until I had the entire
folder path built, then I would just add the file to this final folder

Answer #2    Answered By: Shara Johnson     Answered On: Jan 14

I know how to add  a file to a folder  once
I can identify the folder. The question here is how to identify the
folder in my custom action. How did you get your folder path?

Answer #3    Answered By: Victoria Bell     Answered On: Jan 14

I know which folder  it's going to, it's not happening with the event handler
like it is in yours.

If you want to know where the file is located, you'll need to look at the
itemURL and parse it to remove the site name, and the root  url, then you'll
have the folder path for the file.

Answer #4    Answered By: Cassidy Sharpe     Answered On: Jan 14

The itemURL is not populated with any value. Here is the URLAction
value: <UrlAction

Neither {ItemUrl} nor {ItemId} is populated with value.

Answer #5    Answered By: Linda Mason     Answered On: Jan 14

You need to look at the URL of the item  you just uploaded, not what's in the

Answer #6    Answered By: Hans Weiss     Answered On: Jan 14

I am confused here. At this point of the process, the
item/document is not uploaded yet, so there is no URL to look at.
Maybe I missed something here.

There is another approach I can try, which uses web services, if I
can't figure out how to upload  a document  to a subfolder by the
approach I described earlier.