473,320 Members | 1,848 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

How to write binary data

27
Hi,I am sending binary data from VB to ASP through HttpSendRequest API.I am getting size of file on ASP(using Request.TotalBytes),which I am sending.Now I want to write it on specific path on server.I tried BinaryRead n BinaryWrite method in ASP,but unable to write.Should I use Binary access method,or anything else?plz suggest me.

I am posting what I have done:
Expand|Select|Wrap|Line Numbers
  1.  Dim BinRead 
  2.     Dim BinWrite
  3.     BinRead=Request.BinaryRead(Request.TotalBytes)
  4. BinWrite=Request.BinaryWrite(BinRead)
  5.  
I am not getting what BinWrite should return(It's content of file or anything else?).
Apr 11 '08 #1
4 6550
jhardman
3,406 Expert 2GB
I've had this problem before, and I got around it by converting the binary code to ascii characters and saved it with a text stream. Check out this article. If you have any trouble converting this code (which I tested with gifs, jpegs, and Microsoft xls files) give me a holler. Let me know if this helps.

Jared
Apr 14 '08 #2
Swan
27
I've had this problem before, and I got around it by converting the binary code to ascii characters and saved it with a text stream. Check out this article. If you have any trouble converting this code (which I tested with gifs, jpegs, and Microsoft xls files) give me a holler. Let me know if this helps.

Jared

Thanks for replying.I tried ADODB.Stream n it worked.There is no need to convert in ASCII code.
Apr 18 '08 #3
jhardman
3,406 Expert 2GB
Thanks for replying.I tried ADODB.Stream n it worked.There is no need to convert in ASCII code.
Glad you got it to work. I tried ADODB.Stream and couldn't get it to work, even though I knew it should. Care to share your code?

Jared
Apr 18 '08 #4
Swan
27
Glad you got it to work. I tried ADODB.Stream and couldn't get it to work, even though I knew it should. Care to share your code?

Jared
I am posting my code for reference:
Expand|Select|Wrap|Line Numbers
  1.  
  2. dim myStream,vntPostedData
  3. vntPostedData = Request.BinaryRead(Request.TotalBytes)
  4.  
  5.     Set myStream = CreateObject("ADODB.Stream")
  6.     myStream.Open
  7.     myStream.Type = 1 ' binary
  8.     myStream.Write(vntPostedData)        
  9.     myStream.SaveToFile("C:\testdata.txt")         
  10.     myStream.Close
  11.  
Apr 22 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: kee | last post by:
Hi All, I am trying to write binary data to a file, which is bmp image: Open "d:\temp\test001.bmp" For Binary Access Write As #1 Put #1, 1, strImage Close #1 *** strImage contains binary...
1
by: Elliot Marks | last post by:
I want to output this data to text and binary files. The binary file contains the garbage you would expect to see if you try to read it with a text editor, but below that the output appears as...
4
by: Philipp Lenssen | last post by:
This drives me crazy: I have a file upload script to save an image on the disk (and later on in the database)... it used to work and now it doesn't, though I didn't change anything within the file...
4
by: Tom Van Ginneken | last post by:
Hi, I need to write binary data to a serial port. I am using this function: #include <unistd.h> ssize_t write(int fd, const void *buf, size_t count); I am able to write a alpha-numeric...
3
by: Billy Smith | last post by:
I'm trying to write a little utility that will write some binary data to a file via a javascript and Windows Script Host under Windows XP. The only way to do this that I can find is to convert...
2
by: Thomi Aurel RUAG A | last post by:
Hy I'm using Python 2.4.2 on an ARM (PXA-270) platform (linux-2.6.17). My Goal is to write a list of bytes down to a file (opened in binary mode) in one cycle. The crux is that a '0x0a' (line...
13
by: zach | last post by:
Can someone help me out, I can't figure out what I'm doing wrong to write to a file in binary mode. What's wrong with my code? <?php $fileName = "something.dat"; $string = "This is a...
1
by: =?Utf-8?B?U3RldmVU?= | last post by:
I have a structure that contains both 32x32 and 16x16 icons plus some text. I want to write all this to an XML file so that I can recover the icons later in an application. Can someone tell me how...
1
by: xiao | last post by:
HI~ guys , I have a program here (Sorry it is very long about 240 lines.) It can read and write the header information successfully but it cannot write the array successfully. I guess there is...
1
by: Sachin Garg | last post by:
I have a program which opens a fstream in binary input+output mode, creating the file if it doesn't exists. But writing doesn't works after reading, it must be something obvious that I am not aware...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.