Upload a file to a different site

R

Rory Becker

Hi all

I have 2 Web sites (Applications). For the purposes of this question let's
say they are to be on 2 different boxes in 2 completely different domains.

My users are going to be moving around from page to page in Site1 and then
they are going to need to upload a file.

This file upload should be to Site2.

I would prefer a solution in which...
.... the user clicks a link/button labelled upload
.... a panel opens up (embedded on the first page)
.... the panel is in reality a frame pointing at a page on the second site
.... this new page offers the upload control.
.... the frame/panel shuts down after upload is complete.

I am open to launching a new page/tab instead if needs be.

There are 3 requirements
1.> The users should not have to navigate back to the first site after the
upload.
- The 2nd site should ideally vanish. Perhaps we can get them to close
a tab or a Div. Not sure really
2.> The upload should only take up bandwidth between Site2 and the browser.
- One previous solution *seemed to be* to access the webservice of Site2
from the server side of site1 which of course meant that Site1 was also taking
a hit on bandwidth.
3.> When the user initially clicks the link to open the upload panel, the
web page must Site1's serverside (I guess some sort of Ajax) in order to
trip it into creating a token which must be used as a part of the URL to
site2.

I am not sure however, how to achieve this.

Does it even make any sense?

I'm kinda stuck of where to start here.

Any help greatly appreciated.
 
A

Allen Chen

Hi Rory
From your description you need a popup page of another web site to handle
the upload file. If my understanding is correct you can try following
steps.

1. In the page of the fist web site, add following javascript to open a new
page of the second web site:
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<script type="text/javascript">

function ShowUploadDialog(){
window.open("http://localhost:10441/Default.aspx",null,
"height=200,width=400,status=yes,toolbar=no,menubar=no,location=no");
}</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<input type="button" onclick="ShowUploadDialog()" value="ClickMe" />
</div>
</form>
</body>
</html>

2. In the page of the second web site, add following code in aspx:
<asp:FileUpload ID="FileUpload1" runat="server" />
<asp:Button ID="Button1" runat="server"
Text="Upload" onclick="Button1_Click" />
In additon, add following code in code behind:
protected void Button1_Click(object sender, EventArgs e)
{
this.FileUpload1.PostedFile.SaveAs("any_path_here");//Save
uploaded file.
Page.RegisterStartupScript("allen_chen", "<script
type='text/javascript'>self.close();</script>");//Register some javascript
to close the window after the file has been saved.

}

I think this is the simplest solution and can meet your first two
requirements. As to your third requirement:
3.> When the user initially clicks the link to open the upload panel, the
web page must Site1's serverside (I guess some sort of Ajax) in order to
trip it into creating a token which must be used as a part of the URL to
site2.
My understanding is you need to pass some information to the upload page.
If so you can use the query string. For example:
window.open("http://localhost:10441/Default.aspx?data1=a",null,
"height=200,width=400,status=yes,toolbar=no,menubar=no,location=no");

In the upload page's code behind you can get it via:
Request.QueryString["data1"]

Please have a try. If you have further questions please feel free to ask.

Allen Chen
Microsoft Online Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
| Date: Thu, 24 Jul 2008 15:04:53 +0000 (UTC)
| Message-ID: <[email protected]>
| From: Rory Becker <[email protected]>
| Subject: Upload a file to a different site
| MIME-Version: 1.0
| Content-Transfer-Encoding: 8bit
| Content-Type: text/plain; charset=iso-8859-1; format=flowed
| X-Newsreader: JetBrains Omea Pro 1098.1
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: host86-143-211-151.range86-143.btcentralplus.com
86.143.211.151
| Lines: 1
| Path: TK2MSFTNGHUB02.phx.gbl!TK2MSFTNGP01.phx.gbl!TK2MSFTNGP04.phx.gbl
| Xref: TK2MSFTNGHUB02.phx.gbl
microsoft.public.dotnet.framework.aspnet:72488
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Hi all
|
| I have 2 Web sites (Applications). For the purposes of this question
let's
| say they are to be on 2 different boxes in 2 completely different domains.
|
| My users are going to be moving around from page to page in Site1 and
then
| they are going to need to upload a file.
|
| This file upload should be to Site2.
|
| I would prefer a solution in which...
| ... the user clicks a link/button labelled upload
| ... a panel opens up (embedded on the first page)
| ... the panel is in reality a frame pointing at a page on the second site
| ... this new page offers the upload control.
| ... the frame/panel shuts down after upload is complete.
|
| I am open to launching a new page/tab instead if needs be.
|
| There are 3 requirements
| 1.> The users should not have to navigate back to the first site after
the
| upload.
| - The 2nd site should ideally vanish. Perhaps we can get them to
close
| a tab or a Div. Not sure really
| 2.> The upload should only take up bandwidth between Site2 and the
browser.
| - One previous solution *seemed to be* to access the webservice of
Site2
| from the server side of site1 which of course meant that Site1 was also
taking
| a hit on bandwidth.
| 3.> When the user initially clicks the link to open the upload panel, the
| web page must Site1's serverside (I guess some sort of Ajax) in order to
| trip it into creating a token which must be used as a part of the URL to
| site2.
|
| I am not sure however, how to achieve this.
|
| Does it even make any sense?
|
| I'm kinda stuck of where to start here.
|
| Any help greatly appreciated.
|
|
| --
| Rory


|
|
 
R

Rory Becker

Hello Allen,

Points 1 and 2 work perfectly Thankyou very much

I think I'm going to repost regarding item3 (the Ajax bit) as I'm getting
very confused between Ajax, Webservices and 2 variations of pagemethods.

Thankyou very much for your help, I'm a lot further along than before Now :)
 
A

Allen Chen

Hi Rory

You're welcome. Please feel free to post new questions in the newsgroup.

Allen Chen
Microsoft Online Support
--------------------
| Date: Fri, 25 Jul 2008 15:37:14 +0000 (UTC)
| Message-ID: <[email protected]>
| From: Rory Becker <[email protected]>
| Subject: RE: Upload a file to a different site
| References: <[email protected]>
| MIME-Version: 1.0
| Content-Transfer-Encoding: 8bit
| Content-Type: text/plain; charset=iso-8859-1; format=flowed
| X-Newsreader: JetBrains Omea Pro 1098.1
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: host86-143-211-151.range86-143.btcentralplus.com
86.143.211.151
| Lines: 1
| Path: TK2MSFTNGHUB02.phx.gbl!TK2MSFTNGP01.phx.gbl!TK2MSFTNGP03.phx.gbl
| Xref: TK2MSFTNGHUB02.phx.gbl
microsoft.public.dotnet.framework.aspnet:72577
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Hello Allen,
|
| Points 1 and 2 work perfectly Thankyou very much
|
| I think I'm going to repost regarding item3 (the Ajax bit) as I'm getting
| very confused between Ajax, Webservices and 2 variations of pagemethods.
|
| Thankyou very much for your help, I'm a lot further along than before Now
:)
|
| --
| Rory

|
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,989
Messages
2,570,207
Members
46,782
Latest member
ThomasGex

Latest Threads

Top