Ask a Question related to ASP, Design and Development.
-
garbagecatcher #1
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
garbagecatcher Guest
-
changing input type file
i would very very much like to change the browse button on the file upload to one of my own am i right in thinking if i create an inhertited... -
Write input text to server file.
:confused; Googlepages is my server. It does NOT support PHP or I suspect any other 'backend'. Problem. I have a quiz application where I... -
HowTo Send Uploaded File with INPUT Type file to Sql Server Image Data Type
I have the following problem: I have the following form client side: <FORM.......> <FORM action="./WZUpload.asp" method="Post"... -
HowTo Send Uploaded File with INPUT Type file to Sql Server Image Data Type ?
I have the following problem: I have the following form client side: <FORM.......> <FORM action="./WZUpload.asp" method="Post"... -
input type=file
is it possible to define a default or start up directory with input type="file" field type? If so, is it also possible to filter by another... -
Aaron Bertrand - MVP #2
Re: Mimic Input Type=File server to server
> On my web server I generate a file, I need to send this
If it's within your network, you can use FileSystemObject and copy the file> file to a different web server.
over \\servername\sharename\ or a mapped drive letter (see
[url]http://www.aspfaq.com/2168[/url]).
Ah. If it's outside of your network, you could use FTP (see> I have no control over the other web server.
[url]http://www.aspfaq.com/2110[/url]).
I'd be very surprised. The construct of an upload is that the component (or> Can I use this same process (XMLHTTP) to read and post a
> file?
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?
Aaron Bertrand - MVP Guest
-
garbagecatcher #3
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...
[url]http://www.google.com/uploadstuff.html[/url]
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
garbagecatcher Guest
-
Aaron Bertrand - MVP #4
Re: Mimic Input Type=File server to server
> A normal user can go to this url, browse for a file on
And google also has a receiving web page, *on their server* that accepts and> their computer and upload it to google.
handles the file.
Do you have such a web page on this web server you can't control?
A
Aaron Bertrand - MVP Guest
-
garbagecatcher #5
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:
[url]http://www.google.com/uploadstuff.html[/url]
<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
garbagecatcher Guest
-
Aaron Bertrand - MVP #6
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...> control?> >Do you have such a web page on this web server you can't
>
> 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:
>
> [url]http://www.google.com/uploadstuff.html[/url]
> <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
Aaron Bertrand - MVP Guest
-
Antonin Foller #7
Re: Mimic Input Type=File server to server
Hi,
Please see 'Upload file using IE+ADO without user interaction - VBS '
article at [url]http://www.pstruh.cz/tips/detpg_uploadvbsie.htm[/url]. 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...> 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
Antonin Foller Guest
-
garbagecatcher #8
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 [url]http://www.google.com/uploadstuff.html[/url])
<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
[url]http://www.perfectxml.com/msxmlAnswers.asp?Row_ID=60[/url]
garbagecatcher Guest
-
Bryan Fritchie #9
Re: Mimic Input Type=File server to server
There are no time stamps on posts, so I have no idea how old this thread is. Did this by chance get resolved with working code? We have the exact same scenario going on now where we need to take a file that is on our local web server, and submit it to another web server at our client's location.
Junior Member
- Join Date
- Jun 2011
- Posts
- 1



Reply With Quote

