codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  Example of Image Upload  hanusoft at 09:28 on Thursday, September 20, 2007
 

Here we are uploading images in File System and storing path in the database.

http://www.hanusoftware.com

Code (ImageUpload.aspx.cs) :-
private void Button1_Click(object sender, System.EventArgs e)
{
// Here I am uploading images in Images folder of C drive.
int intResult=0;
string strPath = @"c:\Images\"+Path.GetFileName(File1.PostedFile.FileName);
SqlConnection con = new SqlConnection("server=.;uid=sa;database=pubs;pwd=");
SqlCommand com = new SqlCommand("Insert into Category(name,imagepath) values(@name,@imagepath)",con);
com.Parameters.Add("@name",TextBox1.Text);
com.Parameters.Add("@imagepath",strPath);
con.Open();
intResult = Convert.ToInt32(com.ExecuteNonQuery());
if(intResult != 0)
{
File1.PostedFile.SaveAs(strPath);
Response.Write("Record Inserted.");
}
}




Software Development Company








CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums
//








Recent Forum Threads
•  Very slow inserts using SqlCommand.ExecuteNonQuery()
•  Re: Problem 1 - Email ids conversion code
•  Re: vector
•  combined 3 functions that do the same thing
•  Re: Finding data in hash
•  Re: login logout ...
•  Visual Basic
•  Re: dynamic crystal report generation
•  sorting 2 arrays


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2008