views:

190

answers:

2

Hi

I am just playing around and trying to make a very simple CMS. Right now I what I do right now is I use "FtpWebRequest" to get the file that they want to change around and stick it into a jquery plugin call html area(rich html editor).

Now I am wondering how could I allow them to add images that are not already hosted? Ie not on imageshack or something.

I am guessing I need to somehow upload the file and then store it somewhere but not sure how to do all that.

Thanks

+2  A: 

A common approach for CMS systems that need to work in low-trust environments (like shared hosting) is to use the FileUpload control, and save the uploaded file as a binary (BLOB) in a database. This avoids dealing with the headache of disk access rights on the web server.

If you're using SQL Server, here's a great article on the database side of things (storing images as BLOBs).

The .NET side of things is pretty straightforward. The FileUpload.PostedFile property has all the information about the uploaded file, including a byte stream of its data.

Rex M
I am looking for a solution without a database.
chobo2
@chobo2 the only viable option, then, is to save the images to disk. The article on the FileUpload control will point you to the basics of that.
Rex M
Ya I was always thinking of saving the disk to the image and not to the database. So are you saying to have a separate place where they upload the images then if they want to use it on the page they link to it? I don't use stuff like wordpress often but I seem to remember they have like a richhtml editor that has a place to add images. Do those editors take just link images or do they allow the user to grab it the path from their harddrive?
chobo2
@chobo2 it's two separate processes. Uploading the image file to the server (and storing it wherever) is one step; a totally separate step is - from the editor interface - selecting a file which is already present on the server, and showing that image in the markup. It is possible to make the user experience seamless so this all happens as one step, but under the hood it is still two.
Rex M
A: 

I'm not overly familiar w/ASP but I came across the following link - ignore the DB part - and thought it might help:

http://www.asp101.com/articles/jacob/scriptupload.asp

malonso
So is your solution to first upload all the images then link to them? Like I thought stuff like wordpress you get a rich html editor and you can like upload your image right into that box.
chobo2
That's basically what I was getting at, yeah. Well when you are "uploading" it, it is being stored on that server in one form or another.
malonso