Eric,
I've done a bit of research on this, and you need to use the
HttpWebRequest class in the System.Net namespace to create a custom web
request that will post a file to an external website. I found a class that
abstracts a lot of the code required:
http://www.c-sharpcorner.com/Code/20...DotNetBugs.asp
Pull this class into your project, and then it will just take a few lines of
code:
MultipartForm mp = new MultipartForm(
http://localhost/AcceptFile.aspx);
mp.sendFile(@"c:\resetlog.txt");
I was able to send my file to a web page that accepted it as a client
upload. You can examine the code of MultipartForm for what code is actually
run. It gets a little bit hairy.
Best regards,
Jeffrey Palermo
"eswanson" <eswanson@discussions.microsoft.com> wrote in message
news:64B80D54-6848-467F-A296-9C763D24EE02@microsoft.com...[color=blue]
> Please read the entire reponse, hopefully this clears up your questions.
>
> The data used that needs to go into the batchupload page comes from a
> server. My problem is that currently I write a file to the server and[/color]
then[color=blue]
> the user has to pick this file and send it up to the batchupload page.[/color]
The[color=blue]
> batchupload page is not one of our page, instead it is another company's
> page. This is there interface to do batch processing. We have no control
> over it. We just call this page "batchupload" with a file and other
> parameters. I am attempting to call the page "batchupload" and send fill[/color]
in[color=blue]
> the parameters with out first creating the file. Is this possible? Do[/color]
you[color=blue]
> understand our problem.
>
> First batchupload is a page from another company. It is used for their
> batch processing. Request parameters include a file <html input[/color]
type=file> -[color=blue]
> does this have to be a file or some other data stream stored on the page[/color]
and[color=blue]
> then sent over to this page?
>
> The html page I sent you would be a page that was written for us to
> communicate with the batchupload page. I can hard code all of the other
> parameters except for the input type=file. Instead of writing out a file,[/color]
I[color=blue]
> would like to buffer the file data into an asp.net page and then just send
> all of the information at once over to the "batchupload" page.
>
> I know that I can use
>[/color]
httpppost(http://www.othercompany.com/batchupload?batchid='123'&programnumbe
r='ABC'&xml=?????????)[color=blue]
> How do I specify the xml, since this variable is a file. What has to be[/color]
in[color=blue]
> the data stream of xml, so that it appears to be a file, but is actually a
> character string?
>
> Hopefully this clears up the confusion.
>
> Thanks
>
> Eric
>
> "Jeffrey Palermo [MCP]" wrote:
>[color=green]
> > Eric,
> > I'm not sure I know exactly what you are trying to do, but if the[/color][/color]
file[color=blue][color=green]
> > is coming from a user's machine, you can't automatically grab it. That
> > would be a security issue. If the file is originating on the server,[/color][/color]
then[color=blue][color=green]
> > there is no need for one page to grab it and post it to another page.[/color][/color]
The[color=blue][color=green]
> > second page could just use the absolute path on the server or the[/color][/color]
network to[color=blue][color=green]
> > open the file.
> >
> > Try reposting this question to the newsgroup, be more specific.
> >
> > Best regards,
> > Jeffrey Palermo
> >
> > "eswanson" <eswanson@discussions.microsoft.com> wrote in message
> > news:14C47C45-5C8A-450D-BAFE-2A8141E850B8@microsoft.com...[color=darkred]
> > > Hi Jeff,
> > >
> > > Here is an example that does this in HTML, but I would like to do this[/color][/color][/color]
in[color=blue][color=green][color=darkred]
> > > asp.net, but I do not want to create the file first, instead I would[/color][/color][/color]
like[color=blue][color=green]
> > to[color=darkred]
> > > somehow stream the data to this post instead of writing out the file[/color][/color][/color]
first[color=blue][color=green][color=darkred]
> > > and then having the user select the file and transfering it up to the[/color][/color][/color]
host[color=blue][color=green][color=darkred]
> > > site. Is this possible?
> > >
> > > Here is the current html:
> > >
> > > <form method="post" enctype="multipart/form-data"
> > >[/color][/color][/color]
action="https://egov.immigration.gov/sbtsevisbatch/action/batchUpload"/>[color=blue][color=green][color=darkred]
> > > <!--<form method="post" enctype="multipart/form-data"
> > >[/color][/color][/color]
action="https://egov.immigration.gov/sbtsevisbatch/action/batchUpload">-->[color=blue][color=green][color=darkred]
> > > XML: <input type="file" name="xml" id="xml="><br>
> > > Batch ID: <input type="text" name="batchid" id="batchid="><br>
> > > Program Number: <input type="text" name="programnumber"
> > > id="programnumber="><br>
> > > <input type="submit">
> > >
> > > I am attempting to automated the input type="file", instead I would[/color][/color][/color]
like[color=blue][color=green]
> > to[color=darkred]
> > > stream the file data from an asp.net page without first creating a[/color][/color][/color]
file[color=blue][color=green]
> > and[color=darkred]
> > > then having the user select this file and transmitting it up to the[/color][/color][/color]
other[color=blue][color=green][color=darkred]
> > > site. What other options do I have instead of creating the file first[/color][/color][/color]
or[color=blue][color=green]
> > is[color=darkred]
> > > it possible to tell the input type='file' exactly what the file is and[/color]
> > where[color=darkred]
> > > it is?
> > >
> > > Thanks
> > >
> > > Eric
> > >
> > > "Jeffrey Palermo [MCP]" wrote:
> > >
> > > > You would do this exactly the same as you would do it in regular[/color][/color][/color]
HTML[color=blue][color=green][color=darkred]
> > > > without ASP.NET. In fact, you don't have to use server controls for[/color]
> > this.[color=darkred]
> > > > You can use a normal form and normal <input type="file"/>, <input
> > > > type="submit"/> controls, and set the action of the form to the[/color][/color][/color]
other[color=blue][color=green]
> > page.[color=darkred]
> > > > Don't use a runat="server" form. A regular form will do. Then in[/color][/color][/color]
the[color=blue][color=green]
> > page[color=darkred]
> > > > you post to, just retrieve the form values.
> > > >
> > > > Best regards,
> > > > Jeffrey Palermo
> > > >
> > > > "eswanson" <eswanson@discussions.microsoft.com> wrote in message
> > > > news:CDA3312F-AA93-4821-835C-C07E2503C2E2@microsoft.com...
> > > > > I have a web page I need to post a file plus some other fields to[/color][/color][/color]
it.[color=blue][color=green]
> > How[color=darkred]
> > > > > can I do this from a asp.net page. I know I can send individual[/color][/color][/color]
fields[color=blue][color=green]
> > to[color=darkred]
> > > > the
> > > > > other page, but how do I send a file to the other page, or is[/color][/color][/color]
there[color=blue][color=green][color=darkred]
> > > > something
> > > > > else like a stream which will be like a file. I am attempting to[/color][/color][/color]
get[color=blue][color=green]
> > a[color=darkred]
> > > > way
> > > > > from writing out a file and then having to give the page that I am[/color]
> > posting[color=darkred]
> > > > to
> > > > > the file name. Instead I would like to just from asp.net post to[/color][/color][/color]
the[color=blue][color=green][color=darkred]
> > > > other
> > > > > HTML page, the information, plus this file without writing a file[/color][/color][/color]
out[color=blue][color=green][color=darkred]
> > > > first.
> > > >
> > > >
> > > >[/color]
> >
> >
> >[/color][/color]