473,385 Members | 1,325 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,385 software developers and data experts.

Insert binary data into HTML

multi
8
Hi all,
my question is :

is it possible to insert binary (like attachment) data into html, after that on client-side with javascript or ajax to get this data (download) from this html ?!
give me some ideas, hints or anything :(

Thank you !
Feb 5 '07 #1
4 10792
acoder
16,027 Expert Mod 8TB
Welcome to The Scripts.

I'm not sure I understand. HTML is client-side, so what do you mean by inserting binary data into HTML? Do you mean, you want to force a download when you come to a page? Do you want to use AJAX to get binary data from the server?
Feb 5 '07 #2
multi
8
i mean, you have a html document on the client side, who contains jpeg binary data of an jpeg in base64 encoding, i have js decoder from base64 to binary (something like that) an i want to, after pressing a button or something else some event... to starts "downloading" this data, from the html.
is it possible ?
Feb 5 '07 #3
acoder
16,027 Expert Mod 8TB
I don't know if this is possible on the client-side, but you can set the Content-Disposition header using server-side code which suggests to the browser how a file should be dealt with. Inline usually displays in the browser, but if you set it to 'attachment', it suggests that the user should be asked what to do (including saving to disk). Set the mime-type to image/jpg or whatever the file.

There is no foolproof reliable way to do this, but it should be possible by setting the correct headers.
Feb 5 '07 #4
UniDyne
18
If I am reading your question correctly, you want to pass some sort of encoded binary information in the HTML page to be read in by a JavaScript that is included on that page.

To do this, the binary content will need to be Base64 encoded or somesuch. Browsers get ugly when raw binary data appears in the HTML. There are plenty of places you can find a JavaScript Base64 decoder.

You can simply place the Base64 encoded content inside a hidden DIV tag or TEXTAREA. You could also use the <![CDATA[....]]> tag to hold the encoded data for extra safety. So, what you would have is something like this:

Expand|Select|Wrap|Line Numbers
  1. <div id="mydata" style="display:none"><![CDATA[SGVsbG8gV29ybGQh]]></div>
For a Base64 decoder, check http://rumkin.com/tools/compression/base64.php.
Feb 6 '07 #5

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

Similar topics

0
by: news | last post by:
I have no idea if this is a Linux issue or PHP. Looking for clues here. I have a PHP script which I use to upload a CSV spreadsheet into a mySQL database. (The script follows here in a sec.) I...
2
by: Niraj | last post by:
Hi, I am trying to do bulk insert of binary data (array of bytes) in an Oracle table. The data type of the table is BLOB. I am using Oracle Objects for OLE (OO4O) in C++. The binary data that I...
20
by: akej via SQLMonster.com | last post by:
Hi, i have table with 15 columns CREATE TABLE . ( PRIMARY KEY , NULL , NULL , NULL , NULL , (50) NULL , NULL
24
by: pristo | last post by:
hello All, how can i insert unique ID into binary file (that created by compiler)? (so after compiling i can to identify the src that i use) thx
11
by: Chris Fink | last post by:
I have setup an Oracle table which contains a blob field. How do I insert data into this field using C# and ADO.net?
11
by: Ted | last post by:
OK, I tried this: USE Alert_db; BULK INSERT funds FROM 'C:\\data\\myData.dat' WITH (FIELDTERMINATOR='\t', KEEPNULLS, ROWTERMINATOR='\r\n');
6
by: Ted | last post by:
I used bcp to produce the apended format file. How can it be modified to recognize the quotes that surround the text fields and not insert the quotes along with the text? Invariably, the first...
4
by: mathon | last post by:
Hello, im currently implementing a binary search tree means, that a greater number than root will be added as right child and a less number as left child. My insert function looks currently like...
6
by: Gregor =?UTF-8?B?S292YcSN?= | last post by:
Hi! I'm using JDBC to connect to DB2. I have a binary data (array of bytes) and want to save them. Is it possible to write an INSERT statement to do this: INSERT INTO TABLE (ID, BYTES)...
1
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.