Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Uploading a file to a CGI script

Reply
Thread Tools

Uploading a file to a CGI script

 
 
Rex
Guest
Posts: n/a
 
      04-28-2005
I need to upload a file to a CGI script on a local webserver from my
application. I'm using the following code:

FileInputStream tInputStream = new
FileInputStream(mtCurrentIcon);
ByteArrayOutputStream tBuffer = new
ByteArrayOutputStream();
int iBytes = 0;
// Read the file.
while ((iBytes = tInputStream.read())!= -1) {
tBuffer.write(iBytes);
}

URLConnection tConnection = (new
URL(SERVER_HOST+"/upload.cgi")).openConnection();
System.out.println(tConnection.getURL().getPath()) ;
tConnection.setUseCaches(false);
tConnection.setDoOutput(true);
OutputStream tOutStream = tConnection.getOutputStream();
tOutStream.write(tBuffer.toByteArray());
tOutStream.flush();
tOutStream.close();
This does not work-neither is it able to contact the server (the
access/error logs come up empty), nor is any exception generated.
Is there a better way?

 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to convert exe file of cgi script into .cgi extension. Muzammil C++ 1 08-28-2008 07:50 PM
what's wrong calling a Perl/CGI script in Perl/CGI script under Tomcat server? kath Perl Misc 4 04-09-2007 09:21 PM
ftp uploading vs. control panel uploading Dung Ping HTML 10 01-16-2006 10:43 AM
Question about uploading bin file to cgi from java application rp Java 0 11-17-2003 02:11 PM
CGI module: getting cgi params from text file redirected to script run on the commandline fatted Perl Misc 1 07-25-2003 01:44 AM



Advertisments