Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 How can i convert an image to a base64encoded data

Author  Topic 

blob
Starting Member

16 Posts

Posted - 2006-01-04 : 04:34:40
Hi,
I need to convert an image to a base64 encoded data using csharp web application..Can anybody plz suggest me some ideas on how to convert an image to base64 encoded data.
Thanks in advance for any help.
Regards
blob

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2006-01-04 : 06:49:12
http://www.vbforums.com/showthread.php?t=287324

Go with the flow & have fun! Else fight the flow
Go to Top of Page

blob
Starting Member

16 Posts

Posted - 2006-01-04 : 07:18:11
Hi spirit1,
Thank u for ur immediate response and your help..
Still,i cudn get out of it..
Convert.ToBase64String() function accepts only string as input..
I need to give image file as input..
This is my code..but not successful..

selectedFile = File1.PostedFile;
binaryImagedata = new byte[selectedFile.ContentLength];
binaryImagedata = Convert.ToBase64String(binaryImagedata); selectedFile.InputStream.Read(binaryImagedata,0,selectedFile.ContentLength);

Any ideas plz..
Thanks for any help
Regards
blob
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2006-01-04 : 07:53:56
this says you can pass a byte array as input:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemconvertclasstobase64stringtopic.asp

i think you need to pass 2 more parameters in.


Go with the flow & have fun! Else fight the flow
Go to Top of Page

blob
Starting Member

16 Posts

Posted - 2006-01-05 : 00:06:01
It really works..
Thank you spirit1..
Regards
blob
Go to Top of Page
   

- Advertisement -