?
Solved

Post binary data?

Posted on 2004-11-03
11
Medium Priority
?
420 Views
Last Modified: 2011-10-03
Ive got to create a page which will

Accept binary data (2 jpeg images) and save it on the server.

Now I could do this with filechoosers, but they arent an option - the binary data is created in a Java Applet, and should be POSTED to the page im creating, which will save the images to disk on the server.

I don't have to worry about how the data is posted - I just neeed to grab it in this page and save it to disk - it must be done programatically (so no user interaction, filechoosers etc).

How is this done? Anything to do with HttpWebResponse?
0
Comment
Question by:betocarranza
  • 3
  • 3
  • 2
  • +2
10 Comments
 
LVL 28

Expert Comment

by:mmarinov
ID: 12481708
Hi betocarranza,

let me see if i understand the question and scenario correct:
the user uses java applet to save images to the server disk
you want to grab that images from the disk and insert them in the database ? if yes, when do you want to grab them - by default on some schedule or from the page that contains the applet ?

Regards!
B..M
0
 
LVL 2

Author Comment

by:betocarranza
ID: 12481725
Hi there,

Basically I can ignore the applet - I need a page which can accept 2 images (in binary form) through HTTP POST, and save this to disk. Im just not sure how to do this.

I know how to do it if I use a filechooser, creating streams etc, but how do I do this if the data is POSTED to the page?

Thanks
0
 
LVL 28

Expert Comment

by:mmarinov
ID: 12481844
betocarranza,
unfortunatelly i can not think of a way of doing this ( the posting of image )
check this article if it can help you : http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/ASP_DOT_NET/Q_20971993.html
B..M
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 22

Expert Comment

by:CJ_S
ID: 12481852
Should be pretty simple.

1) Add the following html control to the .aspx page
<input id="ufPreview" type="file" runat="server">

2) set the enctype of the form to multipart/form-data
<form enctype="multipart/form-data" runat="server">

3) If using a codebehind add the following declaration:
Protected ufPreview as HtmlControls.htmlInputFile

4) Upload / Save the file with the following code:
Dim postFile as httpPostedFile = ufUiting.PostedFile
Dim sFileName as string = postFile.FileName.substring(postFile.FileName.lastIndexOf("\")+1)
postFile.SaveAs(String.Concat(Server.MapPath("your/location/"), sFileName))

CJ.
0
 
LVL 22

Expert Comment

by:CJ_S
ID: 12481854
Dim postFile as httpPostedFile = ufUiting.PostedFile
should be
Dim postFile as httpPostedFile = ufPreview .PostedFile
0
 
LVL 6

Expert Comment

by:Volkan Vardar
ID: 12483124
yes you can achieve this.
java applet should use
HTTP-POST and in header -> Content-Type: multipart/form-data

I never tried but I know that you can do what you want.
0
 
LVL 2

Author Comment

by:betocarranza
ID: 12483234
Okay, Ive figured it out on my own -

Using Request.Files.Item(i).InputStream lets me directly grab the bytes from a posted file, which can then be converted to an image and saved to disk.

Thanks for the answers, but none of them were really what I was looking for.
0
 
LVL 22

Expert Comment

by:CJ_S
ID: 12484218
betocarranza,
I'm glad to hear that you've solved your problem. My sample also does the same. Why was it not what you wanted?

regards,
CJ.
0
 
LVL 2

Author Comment

by:betocarranza
ID: 12484578
Hi CJ_S,

What I was looking for was simply a page which, upon loading, would save all binary data sent to it via HTTP POST. Your solution required putting controls on the page (an html file input), which I specifically said I wasn't looking for.

Thanks for your help however,

Jamie
0
 
LVL 1

Accepted Solution

by:
GhostMod earned 0 total points
ID: 12519870
PAQd, 250 points refunded.

GhostMod
Community Support Moderator
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses
Course of the Month16 days, 11 hours left to enroll

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question