473,830 Members | 2,183 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.CreateOb ject("Microsoft .XMLHTTP")
xml.Open "POST", "https://domain.com/login.asp", False
xml.setRequestH eader "lastCached ", now()
xml.setRequestH eader "Content-Type", "applicatio n/x-www-
form-urlencoded"
xml.Send "username=usern ame&password=pa ssword"
Response.Write xml.responseTex t
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
Jul 19 '05 #1
7 5076
> On my web server I generate a file, I need to send this
file to a different web server.
If it's within your network, you can use FileSystemObjec t and copy the file
over \\servername\sh arename\ or a mapped drive letter (see
http://www.aspfaq.com/2168).
I have no control over the other web server.
Ah. If it's outside of your network, you could use FTP (see
http://www.aspfaq.com/2110).
Can I use this same process (XMLHTTP) to read and post a
file?


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?
Jul 19 '05 #2
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="uploadThi sFile">
<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="fal se"
throwonerror="n o"
timeout="15">
<cfhttpparam
type="FILE"
name="IsPost"
file="c:\path\m yfile.jpg">
</cfhttp>

I'm trying to do that exact call, using ASP instead
Jul 19 '05 #3
> A normal user can go to this url, browse for a file on
their computer and upload it to google.


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
Jul 19 '05 #4
>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="uploadThi sFile">
<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.CreateOb ject("Microsoft .XMLHTTP")
xml.Open "POST", "http://www.google.com/upload.asp", False
xml.setRequestH eader "Content-Type", "applicatio n/x-www-
form-urlencoded"
xml.Send "uploadThisFile =" //I don't know how to read or
post the file
Set xml = Nothing
Jul 19 '05 #5
Never tried it, but maybe you could play with adodb.stream, e.g. something
like this:

<%
set adoStream = CreateObject("A DODB.Stream")
adoStream.mode = 3
adoStream.type = 1
adoStream.open
adoStream.loadF romFile "c:\path\file.e xtension"
data = adoStream.read( adoStream.size) ' may need set here?
set adoStream = nothing

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


"garbagecatcher " <ga************ @hotmail.com> wrote in message
news:03******** *************** *****@phx.gbl.. .
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="uploadThi sFile">
<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.CreateOb ject("Microsoft .XMLHTTP")
xml.Open "POST", "http://www.google.com/upload.asp", False
xml.setRequestH eader "Content-Type", "applicatio n/x-www-
form-urlencoded"
xml.Send "uploadThisFile =" //I don't know how to read or
post the file
Set xml = Nothing

Jul 19 '05 #6
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 " <ga************ @hotmail.com> wrote in message
news:01******** *************** *****@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.CreateOb ject("Microsoft .XMLHTTP")
xml.Open "POST", "https://domain.com/login.asp", False
xml.setRequestH eader "lastCached ", now()
xml.setRequestH eader "Content-Type", "applicatio n/x-www-
form-urlencoded"
xml.Send "username=usern ame&password=pa ssword"
Response.Write xml.responseTex t
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

Jul 19 '05 #7
Thank you for all your suggestions,

It seems like it is the right track to use ADODB.Stream
and MSXML2.ServerXM LHTTP.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("A DODB.Stream")
adoStream.mode = 3
adoStream.type = 1
adoStream.open
adoStream.loadF romFile "File.txt"
data = adoStream.read( adoStream.size) ' may need set here?

Set xml = Nothing
Set xml = Server.CreateOb ject("MSXML2.Se rverXMLHTTP.4.0 ")
Response.Buffer = True
xml.Open "POST", "http://www.google.com/upload.asp?
inputName=File" , False
xml.setRequestH eader "lastCached ", now()
xml.setRequestH eader "Content-Type", "applicatio n/x-www-
form-urlencoded"
xml.Send data
Response.write xml.responseTex t
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

Jul 19 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
4785
by: Nathan | last post by:
I have an aspx page with a data grid, some textboxes, and an update button. This page also has one html input element with type=file (not inside the data grid and runat=server). The update button will verify the information that has been entered and updates the data base if the data is correct. Update will throw an exception if the data is not validate based on some given rules. I also have a custom error handling page to show the...
4
9095
by: SammyBar | last post by:
Hi all, I wonder is it possible to upload the content of an <imgfield to a server. The content of the <imgwas downloaded from a web site different from the one it should be uploaded. The image file should not be saved locally before uploading. It should not be visible any <input type=file on the form. How can it be done? I'm working on a project where client javascript requests an image server to generate dynamic images. The client...
0
9793
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10774
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10489
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10525
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9314
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7746
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5780
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4411
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3076
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.