It is a tiny application about “How to upload images?”. User shall provide username, browse file from local machine and once clicks on “add” button the details are saved (database or file system). Please find the code above for your reference In the above source code you can observe that the file(image) uploaded by client is saved using a class “UserDetailsData” which is created exclusively to save or retrieve user details which is user name and relative of the uploaded image file at server. There 2 ways of uploading image file. 1) If you use data base , you create a table with column say “Image” whose data type should be BLOB (Binary Large Object). While inserting a row into this table you can insert the byte stream of the image file uploaded at this column and while retrieving you should type cast the blob data to byte[] array and save into a file whose src should be used to a img tag to display. 2) The other way in Image column which can be Varchar , you can just save the uploaded image and save to application server local disk and whose file path can be saved in this Image column. While retrieving you can read the path and assign it directly to img tag as src.
In the above example I have done it using (2) but since I am not Orcale data base server , so I used serialization concept to save user name and image file path into a data table and then writing the state of data table to a text file (Object persistence).
|
8 comments:
how to bind data to formview
Hi chandra sekhar,
please find my comments regarding how to upload images for fomr view.
how to differentiate between user and administrator roles in login page.
"i need some pages that are accessable to admin but not to users".
how to deploy website which is having database.
Hi chandra sekhar,
Regarding how to diferentiate between a user and administrator it all depends upon the available data for a user in your application data base.
There should be a seperate table that stores user name and roles.
So that when the user loggins into application you should query this roles table and get his priviliges and store in a session object.
Later depending upon the business requirements you can control a module being accessed by a user based upon his priviliges.
Ex:-
There can be a generic function defined which returns boolean (true/false) when you pass user namd and role as parameters.
public bool IsUserPriviliged(string strUserName,string strRoleName)
{
/*code to check either in session variable or directly query the data base with the given parameters as where clause.
Suggessted o query database only once while logging in and store in session varaiable*/
return true if user has privs else false;
}
on either page load of that specifc page or on click of link you can use this function, either to redirect to that page or show insufficient priviliges page.
Cheers
Hi ,
Regaring "how to deploy a website having databse?"
On working at real time basis there can be application installed on a machine (application server) and database installed on another machine (database server).
So thing is when you depoly your application you install your web site at application server, configure your application server to a databse server (databse configuration tools by specific parties), then mention that data base connection string (i hope you define that in configuration (web.config in .net)
file of your application) in your application configuration file.
Cheers,
this is pavan kumar i am having a doubt in asp.net
what is user defined control
explain me with an example program
hi pavan,
sorry again for this delay response. Can you please post you queries or answers from now in my latest blogs to get quick response.
Regarding User Controls look at blog
http://programmerfindings.blogspot.com/2008/10/what-is-user-control.html
Post a Comment