473,769 Members | 3,893 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

vb.net cgi uploading files

Hi all,

I'm trying to do what I consider to be a fairly simple task, yet I'm
having a heck of a time getting it to work. I'm trying to upload a
file (without user intervention and a browser) from a vb.net client
(using webclient or httpwebrequest) to a webserver running a cgi script
to store it on the webserver.

I'm not familiar with perl/cgi very well and am really struggling with
it. I kind of got it to partially work with webclient object and using
uploadvalues by sending the data in namedata collection. However, I
was only able to send half the file (according to the messagebox)
before I started getting 408 request timeout errors. (I determined
this by just sending half the file in the string instead of the whole
file contents).

Any help at all would be great. here are some snippets of my basic
flow. It may not be exact, but you can get the feel.

in VB.net:

Dim myQueryStringCo llection As New NameValueCollec tion

myQueryStringCo llection.Add("f ile", "C:\LogFile ")
myQueryStringCo llection.Add("d ata", dataContents) - a string
containing the log file contents

myWebClient = New WebClient
myWebClient.Cre dentials = New NetworkCredenti al("", "")
httpresponsearr ay = myWebClient.Upl oadValues(txtDe st.Text, "POST",
myQueryStringCo llection)
MsgBox(Encoding .ASCII.GetStrin g(httpresponsea rray)) 'show
results
in CGI: (very simple just to see if the script is receiving)

#!/usr/bin/perl -w

use CGI;

print "Content-type: text/html\n\n";
print "<html><bod y>";

$query = new CGI;

$filepath = $query->param ('file');
$dest = $query->param ('data');

$destfile = "C:\\uploads\te st.txt";
print $dest, "<br>";
print "Your file ($destfile) has been successfully uploaded.","<br >";
print "</body></html>";

Any ideas what is wrong, are there better ways to do this ? If someone
has already done this and has some code they would share, that would be
SOOOOO great.

Mark

Nov 23 '05 #1
4 3877
You can find that how to implement uploading files in RFC-1867 and does not
using the CGI Module!

<ma*****@yahoo. com> ???
news:11******** *************@g 14g2000cwa.goog legroups.com ???...
Hi all,

I'm trying to do what I consider to be a fairly simple task, yet I'm
having a heck of a time getting it to work. I'm trying to upload a
file (without user intervention and a browser) from a vb.net client
(using webclient or httpwebrequest) to a webserver running a cgi script
to store it on the webserver.

I'm not familiar with perl/cgi very well and am really struggling with
it. I kind of got it to partially work with webclient object and using
uploadvalues by sending the data in namedata collection. However, I
was only able to send half the file (according to the messagebox)
before I started getting 408 request timeout errors. (I determined
this by just sending half the file in the string instead of the whole
file contents).

Any help at all would be great. here are some snippets of my basic
flow. It may not be exact, but you can get the feel.

in VB.net:

Dim myQueryStringCo llection As New NameValueCollec tion

myQueryStringCo llection.Add("f ile", "C:\LogFile ")
myQueryStringCo llection.Add("d ata", dataContents) - a string
containing the log file contents

myWebClient = New WebClient
myWebClient.Cre dentials = New NetworkCredenti al("", "")
httpresponsearr ay = myWebClient.Upl oadValues(txtDe st.Text, "POST",
myQueryStringCo llection)
MsgBox(Encoding .ASCII.GetStrin g(httpresponsea rray)) 'show
results
in CGI: (very simple just to see if the script is receiving)

#!/usr/bin/perl -w

use CGI;

print "Content-type: text/html\n\n";
print "<html><bod y>";

$query = new CGI;

$filepath = $query->param ('file');
$dest = $query->param ('data');

$destfile = "C:\\uploads\te st.txt";
print $dest, "<br>";
print "Your file ($destfile) has been successfully uploaded.","<br >";
print "</body></html>";

Any ideas what is wrong, are there better ways to do this ? If someone
has already done this and has some code they would share, that would be
SOOOOO great.

Mark

Nov 23 '05 #2
I don't want something form based though because this will be executing
behind the scenes in the background of the app.

Nov 23 '05 #3
I don't want something form based though because this will be executing
behind the scenes in the background of the app.

Nov 23 '05 #4
ma*****@yahoo.c om wrote in news:1131466692 .289424.79440
@g14g2000cwa.go oglegroups.com:
I'm not familiar with perl/cgi very well and am really struggling with
There is no such monster called perl/cgi. There is the Perl language and
the CGI protocol. Failing to partition the problem leads to wasted time.
#!/usr/bin/perl -w

use CGI;

print "Content-type: text/html\n\n";
print "<html><bod y>";

$query = new CGI;

$filepath = $query->param ('file');
$dest = $query->param ('data');

$destfile = "C:\\uploads\te st.txt";
print $dest, "<br>";
print "Your file ($destfile) has been successfully uploaded.","<br >";
print "</body></html>";

Any ideas what is wrong, are there better ways to do this ? If someone
has already done this and has some code they would share, that would be
SOOOOO great.


Yes, someone has already done it. The correct ways to submit the upload, as
well as to process it are explained in the CGI.pm documentation.

Sinan
Nov 23 '05 #5

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

Similar topics

4
2779
by: dickiedyce | last post by:
Hi there. I've spent the weekend getting ever more frustrated, trying to get an upload file function working on a website. The site is hosted by a company called oneandone. They're using PHP 4.2. 3, not in safe mode. I think that the basic problem is the set-up for the temp folder, but I don't have access to the .ini settings. I'm pretty sure it's possible, because I've got MyPHPAdmin running, and
5
7837
by: Kevin Ollivier | last post by:
Hi all, I've come across a problem that has me stumped, and I thought I'd send a message to the gurus to see if this makes sense to anyone else. =) Basically, I'm trying to upload a series of files via FTP. I'm using ftplib to do it, and for each file I'm using transfercmd("STOR " + myfile) to get the socket, then uploading 4096 bytes at a time and providing status updates via a GUI interface. Finally, I close the socket, set it to...
5
5477
by: Ron Brennan | last post by:
Good afternoon. The entire task that I'm trying to achieve is to allow a user to browse and upload multiple files simultaneously, hiding the Browse button of <input> tags of type="file" and replacing it with a button of my own background color and text. The file paths I'd like displayed in a textarea and then the files uploaded at once.
13
4321
by: Sky Sigal | last post by:
I have created an IHttpHandler that waits for uploads as attachments for a webmail interface, and saves it to a directory that is defined in config.xml. My question is the following: assuming that this is suppossed to end up as a component for others to use, and therefore I do NOT have access to their global.cs::Session_End() how do I cleanup files that were uploaded -- but obviously left stranded when the users aborted/gave up writting...
0
2210
by: Raj | last post by:
Hello, I am planning to provide the Pause/Resume while uploading files. Our site is using both java applet and activex to do this. The list of selected files will be stored in an encrypted file using SHA256 (I have taken the code from: http://www.vbforums.com/showthread.php?s=&threadid=232284)
221
367725
Atli
by: Atli | last post by:
You may be wondering why you would want to put your files “into” the database, rather than just onto the file-system. Well, most of the time, you wouldn’t. In situations where your PHP application needs to store entire files, the preferred method is to save the file onto the server’s file-system, and store the physical location of the file in your database. This is generally considered to be the easiest and fastest way to store files. ...
2
2343
by: =?ISO-8859-1?Q?=22=C1lvaro_G=2E_Vicario=22?= | last post by:
jodleren escribió: I haven't found the PHP manual page where such feature is documented but a few tests have shown that this behaviour changes depending on the charset parameter of the "Content-Type" HTTP header; even if I don't set an actual HTTP header and I just use a <metatag: <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> With a packet sniffer I've determined that it's not the browser who
1
726
by: =?Utf-8?B?RGFu?= | last post by:
MS won't seem to let me reply to my old post, so I created a new one. The error occurs in all browsers. It's definitely a server issue, not client. The server is not proxied in any way. I tried uploading the files on the server and experienced the same issues as I get on any other computer. Thanks in advance for your help. Dan
3
5182
by: muziburrehaman | last post by:
i am looking for code in php to upload the 1 gb files. any one can please help me by sending the code....
0
2782
by: LoriFranklin | last post by:
I'm a bit of a newbie here. I've learned a lot from reading the posts you all have here. I need some help uploading files using an asp form. I am using some code that I found from Jacob at asp101.com. http://www.asp101.com/articles/jacob/scriptupload.asp My three files are: Syllabus.htm <?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
0
9589
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
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10045
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
7408
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
6673
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3958
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
2
3561
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
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.