Post binary data?

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?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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 ?

betocarranzaAuthor Commented:
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?

unfortunatelly i can not think of a way of doing this ( the posting of image )
check this article if it can help you :
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

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))

Dim postFile as httpPostedFile = ufUiting.PostedFile
should be
Dim postFile as httpPostedFile = ufPreview .PostedFile
Volkan VardarSoftware Team LeaderCommented:
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.
betocarranzaAuthor Commented:
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.
I'm glad to hear that you've solved your problem. My sample also does the same. Why was it not what you wanted?

betocarranzaAuthor Commented:
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,

PAQd, 250 points refunded.

Community Support Moderator

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.