Hi
Using FileUpload control to upload the image I have given the coding as
[code=cpp]
using System;
using System.Data;
using System.Configur ation;
using System.Web;
using System.Web.Secu rity;
using System.Web.UI;
using System.Web.UI.W ebControls;
using System.Web.UI.W ebControls.WebP arts;
using System.Web.UI.H tmlControls;
using System.IO;
using System.Data.Sql Client;
using System.Net.Mail ;
public partial class _Default : System.Web.UI.P age
{
protected void Page_Load(objec t sender, EventArgs e)
{
}
protected void Button1_Click1( object sender, EventArgs e)
{
string s = FileUpload1.Fil eName;
FileInfo ff = new FileInfo(s);
long num = ff.Length;
FileStream ft = new FileStream(s, FileMode.Open, FileAccess.Read );
BinaryReader br = new BinaryReader(ft );
Byte[] data = br.ReadBytes((i nt)num);
SqlConnection con = new SqlConnection(" user id=sa;password= cast;database=H ello_Dr;server= AURORA-SERVER");
con.Open();
SqlCommand cmd = new SqlCommand("ins ert into imgdatastore values('" + data + "')", con);
cmd.ExecuteNonQ uery();
Response.Redire ct("Inserted") ;
con.Close();
}
}
[/code]
but while running, if I upload the jpg file named 'title_1.JPG'.
the error is
Could not find file 'title_1.JPG'.
Using FileUpload control to upload the image I have given the coding as
[code=cpp]
using System;
using System.Data;
using System.Configur ation;
using System.Web;
using System.Web.Secu rity;
using System.Web.UI;
using System.Web.UI.W ebControls;
using System.Web.UI.W ebControls.WebP arts;
using System.Web.UI.H tmlControls;
using System.IO;
using System.Data.Sql Client;
using System.Net.Mail ;
public partial class _Default : System.Web.UI.P age
{
protected void Page_Load(objec t sender, EventArgs e)
{
}
protected void Button1_Click1( object sender, EventArgs e)
{
string s = FileUpload1.Fil eName;
FileInfo ff = new FileInfo(s);
long num = ff.Length;
FileStream ft = new FileStream(s, FileMode.Open, FileAccess.Read );
BinaryReader br = new BinaryReader(ft );
Byte[] data = br.ReadBytes((i nt)num);
SqlConnection con = new SqlConnection(" user id=sa;password= cast;database=H ello_Dr;server= AURORA-SERVER");
con.Open();
SqlCommand cmd = new SqlCommand("ins ert into imgdatastore values('" + data + "')", con);
cmd.ExecuteNonQ uery();
Response.Redire ct("Inserted") ;
con.Close();
}
}
[/code]
but while running, if I upload the jpg file named 'title_1.JPG'.
the error is
Could not find file 'title_1.JPG'.
Comment