Connecting Tech Pros Worldwide Help | Site Map
 
 
LinkBack Thread Tools Search this Thread
  #1  
Old July 19th, 2005, 08:11 AM
garbagecatcher
Guest
 
Posts: n/a
Default Mimic Input Type=File server to server

Hello,

here's my problem:

On my web server I generate a file, I need to send this
file to a different web server.

I have no control over the other web server.

The only way they accept files is through input type="file"

Since I generate the file on my server, I'd like to post
this directly to their server without the user having to
download the file from my server, and go to the other
server to upload it.

Right now I'm using XMLHTTP (post) to login to the other
webserver, this works fine:

Response.Buffer = True
Dim objXMLHTTP, xml
Set xml = Server.CreateObject("Microsoft.XMLHTTP")
xml.Open "POST", "https://domain.com/login.asp", False
xml.setRequestHeader "lastCached", now()
xml.setRequestHeader "Content-Type", "application/x-www-
form-urlencoded"
xml.Send "username=username&password=password"
Response.Write xml.responseText
Set xml = Nothing


Can I use this same process (XMLHTTP) to read and post a
file? What is the syntax for that? I'm not normally an asp
programmer so any detailed instructions would really be
appreciated!

Thanks
  #2  
Old July 19th, 2005, 08:11 AM
Aaron Bertrand - MVP
Guest
 
Posts: n/a
Default Re: Mimic Input Type=File server to server

> On my web server I generate a file, I need to send this[color=blue]
> file to a different web server.[/color]

If it's within your network, you can use FileSystemObject and copy the file
over \\servername\sharename\ or a mapped drive letter (see
http://www.aspfaq.com/2168).
[color=blue]
> I have no control over the other web server.[/color]

Ah. If it's outside of your network, you could use FTP (see
http://www.aspfaq.com/2110).
[color=blue]
> Can I use this same process (XMLHTTP) to read and post a
> file?[/color]

I'd be very surprised. The construct of an upload is that the component (or
script) sits on the server that controls and accepts the files it accepts.
Imagine if you could just upload any arbitrary file to any server of your
choosing?


  #3  
Old July 19th, 2005, 08:11 AM
garbagecatcher
Guest
 
Posts: n/a
Default Re: Mimic Input Type=File server to server

Hey Aaron, thanks for the reply

Unfortunately I cant FTP the information up there

This is what it is like, lets say google has a form on
their website located at...
http://www.google.com/uploadstuff.html

and that page looks like this:

<form name="upload" action="upload.asp" method="post">
<input type="file" name="uploadThisFile">
<input type="submit">
</form>

A normal user can go to this url, browse for a file on
their computer and upload it to google.

I want my webserver to go to this url, and submit a file
(from the webserver), as if it was using input type="file"

Does this make sense? You can do this in cold fusion
through the use of cfhttp, it would look like this:

<cfhttp url="http://www.google.com/upload.asp"
method="POST"
resolveurl="false"
throwonerror="no"
timeout="15">
<cfhttpparam
type="FILE"
name="IsPost"
file="c:\path\myfile.jpg">
</cfhttp>

I'm trying to do that exact call, using ASP instead


  #4  
Old July 19th, 2005, 08:11 AM
Aaron Bertrand - MVP
Guest
 
Posts: n/a
Default Re: Mimic Input Type=File server to server

> A normal user can go to this url, browse for a file on[color=blue]
> their computer and upload it to google.[/color]

And google also has a receiving web page, *on their server* that accepts and
handles the file.

Do you have such a web page on this web server you can't control?

A


  #5  
Old July 19th, 2005, 08:12 AM
garbagecatcher
Guest
 
Posts: n/a
Default Re: Mimic Input Type=File server to server

>Do you have such a web page on this web server you can't
control?

Exactily, and I just need to know how I can send a file
through that form through my webserver. Is this possible
with XMLHTTP?

So to continue with this google concept. If google had a
web page that had this content:

http://www.google.com/uploadstuff.html
<form name="upload" action="upload.asp" method="post">
<input type="file" name="uploadThisFile">
<input type="submit">
</form>

And you needed to submit files from your webserver to
google, using that form. How would you do it? I think it
can be done using something like this (code example
below). I just don't know how to read and post the file:

Response.Buffer = True
Dim xml
Set xml = Server.CreateObject("Microsoft.XMLHTTP")
xml.Open "POST", "http://www.google.com/upload.asp", False
xml.setRequestHeader "Content-Type", "application/x-www-
form-urlencoded"
xml.Send "uploadThisFile=" //I don't know how to read or
post the file
Set xml = Nothing
  #6  
Old July 19th, 2005, 08:12 AM
Aaron Bertrand - MVP
Guest
 
Posts: n/a
Default Re: Mimic Input Type=File server to server

Never tried it, but maybe you could play with adodb.stream, e.g. something
like this:

<%
set adoStream = CreateObject("ADODB.Stream")
adoStream.mode = 3
adoStream.type = 1
adoStream.open
adoStream.loadFromFile "c:\path\file.extension"
data = adoStream.read(adoStream.size) ' may need set here?
set adoStream = nothing

Set xml = Server.CreateObject("Microsoft.XMLHTTP")
xml.Open "POST", "http://www.google.com/upload.asp", False
xml.setRequestHeader "Content-Type", "appl" & _
"ication/x-www-form-urlencoded"
xml.Send "uploadThisFile=" & data
Set xml = Nothing
%>






"garbagecatcher" <garbagecatcher@hotmail.com> wrote in message
news:03bf01c37706$12bc8640$a301280a@phx.gbl...[color=blue][color=green]
> >Do you have such a web page on this web server you can't[/color]
> control?
>
> Exactily, and I just need to know how I can send a file
> through that form through my webserver. Is this possible
> with XMLHTTP?
>
> So to continue with this google concept. If google had a
> web page that had this content:
>
> http://www.google.com/uploadstuff.html
> <form name="upload" action="upload.asp" method="post">
> <input type="file" name="uploadThisFile">
> <input type="submit">
> </form>
>
> And you needed to submit files from your webserver to
> google, using that form. How would you do it? I think it
> can be done using something like this (code example
> below). I just don't know how to read and post the file:
>
> Response.Buffer = True
> Dim xml
> Set xml = Server.CreateObject("Microsoft.XMLHTTP")
> xml.Open "POST", "http://www.google.com/upload.asp", False
> xml.setRequestHeader "Content-Type", "application/x-www-
> form-urlencoded"
> xml.Send "uploadThisFile=" //I don't know how to read or
> post the file
> Set xml = Nothing[/color]


  #7  
Old July 19th, 2005, 08:12 AM
Antonin Foller
Guest
 
Posts: n/a
Default Re: Mimic Input Type=File server to server

Hi,
Please see 'Upload file using IE+ADO without user interaction - VBS '
article at http://www.pstruh.cz/tips/detpg_uploadvbsie.htm. It let's you
prepare document with multipart data to send a file to another server.

Antonin

"garbagecatcher" <garbagecatcher@hotmail.com> wrote in message
news:015701c376f9$878ced00$a401280a@phx.gbl...[color=blue]
> Hello,
>
> here's my problem:
>
> On my web server I generate a file, I need to send this
> file to a different web server.
>
> I have no control over the other web server.
>
> The only way they accept files is through input type="file"
>
> Since I generate the file on my server, I'd like to post
> this directly to their server without the user having to
> download the file from my server, and go to the other
> server to upload it.
>
> Right now I'm using XMLHTTP (post) to login to the other
> webserver, this works fine:
>
> Response.Buffer = True
> Dim objXMLHTTP, xml
> Set xml = Server.CreateObject("Microsoft.XMLHTTP")
> xml.Open "POST", "https://domain.com/login.asp", False
> xml.setRequestHeader "lastCached", now()
> xml.setRequestHeader "Content-Type", "application/x-www-
> form-urlencoded"
> xml.Send "username=username&password=password"
> Response.Write xml.responseText
> Set xml = Nothing
>
>
> Can I use this same process (XMLHTTP) to read and post a
> file? What is the syntax for that? I'm not normally an asp
> programmer so any detailed instructions would really be
> appreciated!
>
> Thanks[/color]


  #8  
Old July 19th, 2005, 08:14 AM
garbagecatcher
Guest
 
Posts: n/a
Default Mimic Input Type=File server to server

Thank you for all your suggestions,

It seems like it is the right track to use ADODB.Stream
and MSXML2.ServerXMLHTTP.4.0, but it still doesn't work
for me.

There are a few things I should mention.

The form that has the input type="file" also has another
section that is required.

So it is like this:
(mytical form at http://www.google.com/uploadstuff.html)
<form action="upload.asp">
<input type="text" name="textName">Name
<input type="file" name="fileName">
</form>


set adoStream = CreateObject("ADODB.Stream")
adoStream.mode = 3
adoStream.type = 1
adoStream.open
adoStream.loadFromFile "File.txt"
data = adoStream.read(adoStream.size) ' may need set here?

Set xml = Nothing
Set xml = Server.CreateObject("MSXML2.ServerXMLHTTP.4.0")
Response.Buffer = True
xml.Open "POST", "http://www.google.com/upload.asp?
inputName=File", False
xml.setRequestHeader "lastCached", now()
xml.setRequestHeader "Content-Type", "application/x-www-
form-urlencoded"
xml.Send data
Response.write xml.responseText
Set xml = Nothing

------
Problems:
I don't see any way to give the data a name,
like "fileName", I think if I can do that I will be golden!

If i try:
xml.Send "fileName=" & data

I get a conversion error.

Any more suggestions?

I also found this article, but it seems to have the same
info
http://www.perfectxml.com/msxmlAnswers.asp?Row_ID=60

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 205,248 network members.