Sunday, December 27, 2009

Image upload in Oracle

Why we upload image in database not in server? search www.google.com 


Here is a sample project that upload image from your local machine and then it uploaded in oracle database. If you want to save the file in server and database then remove the comment at the following line and line number :

 Default.aspx.cs ->line number : 23,24,41,42 


If you want to upload the images server then same file name is uploaded previous is overwritten. But it will still in database. 


Process :
1. Connect oracle in asp.net. To connect oracle in asp.net see here.


2. From previous there is small change in OracleConnect.cs file . A overloaded method is added.  you can download the file from here.

4. A generic handler file is added here to show the image. why it is used? see www.google.com


5. To run the sample project( here ) you need to change the databasename, username and password 4 times. Here is the file names and line numbers
( I used Database name as "XE" username as "project" and password is "12345")


Default.aspx.cs -> line no : 13
MyHandler.ashx->line no : 23
ShowImage.aspx.cs->Line no : 12,32


6. The table schema is here.


7. To show the images you can use GridView ,ListView, DataList, Repeater controls. I used the repeater control. Other controls are used but they are commented. If u want to see the other controls then remove comment in ShowImage.aspx and ShowImage.aspx.cs



So do it. See the sample project and run.
Attachments:
1. sample project 
2. Table schema
3. OracleConnect.cs

For any query comment here or mail "humayun0156@gmail.com" 

No comments:

Post a Comment