In my html webform, I have this
<input type="file" id="txtUploadFile" accept="image/*" onchange="changetext();" />
However, I am not able to read the image data I'm trying to upload since most functions are not available for IE8. Such functions are
Image()
XDomainRequest()
FileReader()
or this.files[0]
I want to be able to send image data to server, so I can get a binary stream or whatever so that I can pass that something to my c# code which saves the picture in my sql database.
My C# code is as follows:
public SRLogoPhoto SaveSRLogoPhoto(string filePath)
{
DataSet ds = null;
Hashtable param = new Hashtable();
SRLogoPhoto srlp = new SRLogoPhoto();
try
{
System.IO.FileStream fs = new System.IO.FileStream(filePath, System.IO.FileMode.Open, System.IO.FileAccess.Read);
Byte[] b = new Byte[fs.Length];
fs.Read(b, 0, b.Length);
fs.Close();
SqlParameter P = new SqlParameter("@Picture", SqlDbType.VarBinary, b.Length, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, b);
string sqlStr = "UPDATE SRSiteLogo SET srImage = @Picture ";
param.Add("Picture", P);
ds = dbHelper.GetDataSet(sqlStr, param);
}
catch (Exception ex)
{
srlp.Error = "SaveSRLogoPhoto() web method failed on call to dbHelper.GetDataSet - " + ex.Message;
}
return srlp;
}
^This currently works when I upload image on my local machine. But when I deploy my webcode on the server, this won't work since it cannot find the filepath I'm trying to pass. Thats why I need to be able to read the data on my html page(javascript/or any language that I can use in an html file)
Thank you in advance. I really need this.