Click here to Skip to main content
16,021,209 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
How can i Insert an Image From Local to Server using LAN?

please help me sir.....!
Posted
Updated 7-Feb-12 19:38pm
v2
Comments
Aniket Yadav 8-Feb-12 1:27am    
What Exactly Does Local To Server Means?

Please Elaborate Little More

Hi,
While upload a image to server, convert a image to as a byte array format and in server datatypes as varbinary or use image datatype.

I attached sample code for convert a image to byte array format,

C#
private byte[] ReadFile(string imgPath,out string imageWidth, out string imageHeight)
    { 
//Check upload file has this format or whatever you like
if (btnFileUpload.HasFile && (btnFileUpload.FileName.EndsWith(".jpg") || btnFileUpload.FileName.EndsWith(".jpeg")))
{
//imgPath is local image path
   FileInfo filePath = new FileInfo(imgPath);            
            long fileLength = filePath.Length;
            FileStream fStream = new FileStream(imgPath, FileMode.Open, FileAccess.Read);
            BinaryReader bReader = new BinaryReader(fStream);
            upLoadImg = bReader.ReadBytes((int)fileLength);   
}
  return upLoadImg;
}
 
Share this answer
 
v2
Comments
Anuja Pawar Indore 8-Feb-12 3:06am    
Added pre tag
Hi,

See my article if could help...

Display/Store and Retrieve Image Data from Database to Gridview

Regards,
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900