Through the website, I need to allow the user to add attachments and store them. And also add pictures and display and store them.
Where's your question? This is a very broad statement and you've not given any details as to what you need. With that said I am going to take a stab and give you a very general high level overview.
To upload files you can use an input control with a type set to file. This will let your user select an attachment.
Once they have selected it and posted to the server you will get access to the files via Request.File
You have a ton of options to store the files:
- Save the files as a blob in a database using an image or binary data type
- Save the file on the file system and store a pointer in your database
- If your using SQL 2008 there's a new file stream data type which is sort of like option 2.
Edit
I recently added attachment capability and some of the things I ran into include:
- IE8 no longer includes the real file path in the input control. It now returns c:\FakePath as
- Make sure to set the encoding type on the form if your not going to user server side controls.
- If you want to upload multiple files a simple method is to have one visible input control, then as the user selects a file hide the input, and replace with a new input. Then provide the user with a list of the files, allowing them to delete the files.
Edit
Ok to do this you need to have a directory which is in iis, that the worker process has write access to, once you save the file, you can build a url for the user. If you have named user accounts you can store the files using the username which will help avoid collisions.
There are loads of tutorials out there, it can be a fairly easy thing to do and you can then make it as complicated as you like to suit your needs. Try these tutorials: they are websites i cannot live without as an ASP.NET developer,
http://www.asp.net/learn/videos/video-255.aspx
http://www.4guysfromrolla.com/webtech/091201-1.shtml
Have fun!
As an outline of where to start:
You will want to use the FileUpload control to allow the uploads.
A database to store which files a user has uploaded.
A display page to build the html to view the pictures / files. Probably using a repeater of some description.
Things to beware of are maximum file sizes of uploads and any security risks with people uploaded files to your server.