Woody Windischman


Something Old In Something New

Mar-262009

Classic

Using legacy FrontPage functionality in SharePoint and SharePoint Designer to create a file "drop box".

SharePoint is a great tool for information sharing. Document libraries allow your users to upload and collaborate on documents of all sorts. Sometimes, though, you don't want to do things quite the way SharePoint does it.

Does this sound familiar?

"I want a place where users can upload a file, but I don't want them to see what everyone else has uploaded."

Your first thought might be no problem, I'll just set up a document library, but what about that bit about seeing what everyone else has uploaded? Now we're getting a bit messy. Document libraries don't have an "only their own" security option.

And what if this is supposed to be a "drop only" zone, such that they aren't even supposed to get back at their own files? (This is a more common request than you might think). Again, very difficult with the standard SharePoint document libraries. Savvy users can figure out how to get to their files based on the address of the forms folder.

While there are many ways to get around these issues, most of them involve a lot of work customizing the target library and its forms. Fortunately, there are some old, but little known, tools in SharePoint and SharePoint Designer that can make short work of the problem.

It's In There...

You may not realize this (unless you've been around a while, or read the Appendix to my book), but SharePoint is a descendent (at least conceptually) of the FrontPage Server Extensions (FPSE). Although there has been a lot of enhancement since then, many of the functions of these extensions still exist within SharePoint in a compatible way. SharePoint Designer, as a descendent of FrontPage, supports this FPSE functionality.

One of the things you may find surprising about the FPSE, is that most of its features are meant to be defined in "static" HTML pages. Specially crafted comments, called WebBots, were used to signal to the server that extra processing was to take place at either save or render time.

For this project, we're going to make use of the FPSE form handler WebBot to let the user select a file and upload it into a hidden document library on your site.

Making it Happen

The first thing you need, of course, is a place to put the files. As stated earlier, the natural target is a document library. So, let's create a library called DropBox.

Note: Most of these steps will take place in SharePoint Designer.

From the File menu, select New, SharePoint Content:

image

Select Document Library, and enter a name, such as DropBox. Click OK to create the library

image

Once the library is created, right-click it and choose Properties. Check the box "Hide from browsers", so that the library doesn't appear in the Quick Launch or All Site Content lists. Set the Use version history to Major Versions. (You want versioning enabled so you don't lose anything if users upload files that have the same name.) Since there won't be a default document type for this library, you can also uncheck the "Use a template" option. Click OK once the settings are correct.

image 

Note: There is one library setting you may wish to make in the browser, to block the library from appearing in SharePoint Search results. Under the Document Library Settings, Advanced Settings, set the Search option to "no".

Once you have created your target library, you create HTML pages to use for your upload form and confirmation page.

From the File menu, select New ->HTML. This will create an html file in the design surface.

From the Toolbox task pane, drag an Input (File) control onto your page.

image

This will automatically create a Form element to surround it.

Drag an Input (Submit) button into the new form as well.

image

I'm using the SharePoint Designer split-view of my page to show both the code and visual layout. Now we need to make a slight change to the automatically created Form element. To do this, we'll click in the code area to place the cursor after the post statement. When you hit space, you will be presented with Intellisense options for parameters you can add to the form tag. In this case, we want to add an "enctype" parameter, and set it to "multipart/form-data", as shown below.

image

image

Without this change, the form will not be able to handle the binary file information we want to transfer. I'm also going to rename the Submit button to say "Upload" by double-clicking it and changing the Value/label field, and also place it on a new line.

image

This results in a form that looks like the image below in the editor:

image

Now that my form has all of the information I want, I'm going to tell it where to place the files. Right-click the form, and select Form Properties. In the Form Properties dialog, select "Send to (Requires FrontPage Server Extensions)". Enter "_private/dropbox.xml" into the File name field. This is not where the files go. Rather, it will be a log of all of the forms that have been submitted. If you add other fields to your form, their values would also be stored in this file.

image

Now, we click the "Options" button, and click the File Upload tab. Click the Browse button and select our DropBox library. Click OK to implement the changes. (Don't worry about the other fields or tabs for right now.)

image

The first time you save your form, you may also get an alert telling you that files not saved in _private may be visible to others.

Save the page in the root of your site as "dropbox.htm" (you can move it later).

At this point, you can test the basic functionality of your form. Preview the page in your browser, and try uploading a file. You should see a confirmation page similar to the following:

image

And if you open the DropBox library in SharePoint Designer, you will see the file there as well (you may need to press the F5 key to referesh the view)

image

The only problem is that confirmation form - you've just told your user where you put the file.

Creating a Confirmation Page

You can also create a custom confirmation page for your form. Again, this starts as a simple, HTML page, so select File -> New -> HTML.

From the Insert menu, select "Web Component". This will summon a dialog box, in which you will select Advancved Controls as the component type, and Confirmation Field for the actual control:

image

Click Finish. You will be asked for the name of the control to use. Type Submit1 and click OK. (Submit1 is the name of the upload button in our form.)

Enter the following text after the form field:

complete!

Thank you for your submission. Click here to return to the form.

Highilight "Click here", and press <ctrl>+k. In the insert hyperlink dialog, select the dropbox.htm file. You should end up with something that looks approximately like:

image

Save the file as "DropConfirm.htm".

Meanwhile, back on the dropbox.htm page, right-click on the form and select Form Properties. Click the Options button, and select the Confirmation Page tab. Click Browse, and select the DropConfirm.htm page you created above.

image

Click OK to save the change, and also on the Properties dialog. Save the dropbox.htm page, and preview it in the browser. Upload a file, and ensure that your new confirmation page is displayed:

image

Using Your Dropbox

Once your form and confirmation page are working to your liking, you need to make them available to your users. The best way to do this is to use a "Page Viewer" web part. This web part allows you to display virtually any page within the context of a SharePoint web part page. We're going to use the standard SharePoint web interface to add this part.

To add the web part, Navigate to the page where you want the form to appear, and select Edit Page from the Site Actions menu. Click the Add a Web Part link in the zone you want. From the dialog, select Page Viewer Web Part. (It will usually be in the Miscellaneous section). And click the Add button.

image

This will add the part to the top of the zone you selected. Click the "open the tool pane" link.

image

That will open the Page Viewer Web Part's task pane:

image

Enter the URL path to your dropbox form in the Link field. I suggest using a "root relative" address (i.e. preceding backslash, but without the " http://server ").

In this case, I also changed the web part title, and set fixed height and width settings for the web part in order to prevent scrollbars (these numbers may vary on your site). Click OK to save your changes, and click the Exit Edit Mode link to see your final page. (You may need to check-in the page on MOSS Publishing sites.)

image

Summary

There you have it! A simple way to give give your users an "upload only" dropbox. You can easily change the destination location for the files, without needing to make any changes to the underlying SharePoint document libraries or their associated forms.

While this example only provided a simple form, you can enhance it with more text, or additional fields for the log file. You can, of course, format the text any way you like, or even make it a stand-alone page, copying all of the chrome from your site (not a trivial task, but possible.)

Until next time, Happy Dropping!

 
Posted by Woody Windischman | 6 Comments | Trackback Url | Bookmark with:        
Tags: Administration, Customization, Design, Lists and Libraries, SharePoint Designer, Training

Links to this Post

Comments

Friday, 1 Oct 2010 03:03 by John Christian
Hi Woody This works brilliantly. Thank you. Is there a way of adapting the code so that the user is presented with a dropdown so that the file can be submitted to one of a choice of folders in the document library? I have fiddled a bit but my HTML skills are not up to the task \i'm afraid Thanks John

Friday, 1 Oct 2010 11:15 by John Christian
Re my previous comment, I have done it after all just using option values to point to different folders in the document library. Thanks for puting me on the right track.

Wednesday, 10 Nov 2010 05:09 by Marah Rutski
Hi Woody, My form will not use my custom confirmation page. It keeps referring to the default confirmation page. Any suggestions?

Wednesday, 10 Nov 2010 05:27 by Woody
Hi Marah, You need to ensure that your confirmation form is an html file, not an aspx file, otherwise the old-style FrontPage components won't operate.

Thursday, 11 Nov 2010 11:06 by Marah Rutski
Unfortunately, it's still not working. I ensured both my form and confirmation page are html; yet the default confirmation page is still intact. I’ve been searching the internet, only to find many are having the same problem with no resolution in site. I’ve tried entering the entire url of the confirmation page and still it defaults. I even just made a simple form with just a text box to test with and I absolutely cannot get the form to use my confirmation page. Do you perhaps have any other suggestions I could try?

Saturday, 11 Dec 2010 08:31 by Woody
Hi Marah! I just confirmed on my site that this works as designed. Key to making it work: 1. The page must be an .htm file. 2. You MUST have one of the fields that exists on your form represented in the confirmation page as a confirmation field. Without those elements, the legacy FrontPage engine doesn't understand that the page really is a confirmation.

Name:
URL:
Email:
Comments: