Create an "Upload a Document" button web part in other document libaries

1. Created a subsite and used the "Document Center" template.
2. Exported the "Upload a Document" button from that site.
3. Uploaded the button web part to the Web Part Library.
4. On the Home page I added the "Upload a Button" web part.
5. The button works on the subsite fine.
6. On the home page the button will not open the "upload.aspx" page.

Here is a copy of the code for the button. They are exactly the same for both the home page and subsite.

<div class="ms-uploadbtnlink"><button onclick="javascript:OpenNewFormUrl(&#39;DropOffLibrary/Forms/upload.aspx&#39;);return false;" type="submit"><nobr><img alt="Upload a Document" src="/_layouts/Images/uploaddoc.png"/>&#160;<span>Upload a Document</span></nobr></button> </div>
Who is Participating?
Rainer JeschorConnect With a Mentor Commented:
this is because the function "OpenNewFormUrl" is only defined on the doc center page (and not on the root site home page).

Thats the function in the doc center:
function OpenNewFormUrl(url)
	var options = {width:720, height:480};
	SP.UI.ModalDialog.commonModalDialogOpen(url, options, null, null);

Open in new window

Either you add the function to your home page or you recode the button click:
<button onclick="javascript:var options = {width:720, height:480};SP.UI.ModalDialog.commonModalDialogOpen('/DropOffLibrary/Forms/upload.aspx', options, null, null);return false;" type="submit">

Open in new window

Please be sure and check the Url of the DropOffLibrary.

Guru JiCommented:
You just have to specify the entire path for the form URL for upload.aspx in the home page.
For instance your website URL is


and your subsite is


then currently your upload for subsite pointing to

you have to give FULL path on the code above
so that it knows which department or subsite library you trying to upload too.

Currently the URL is translated to


and thats why it does not work
mnoisetteAuthor Commented:
Worked like a charm!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.