View Single Post
  #6 (permalink)  
Old April 10th, 2006, 01:23 PM
Imar's Avatar
Imar Imar is offline
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Hi Mike,

You may be getting confused by a few concepts...

The ImageUrl can be simple text, with a length of 255 or so, depending on where you store the image.

When you upload a file, you'll do something like this (pseudo code)

File.Save(Server.MapPath("UserUploads") & "/" & FileName)

assuming that filename holds something like SomeFile.gif.

Next, you save the image URL in the database. All you store in the ImageUrl field is "/UserUploads/SomeFile.gif"

If you need to display the image somewhere on a page, you can use this:

<img src="<%= myRecordset("ImageUrl") %>" alt="" />

This puts an image location like this in the page:

<img src="/UserUploads/SomeFile.gif" alt="" />

which should be the virtual location of your file.

If you ever need to delete the file, you can do something like this (pseudo code again)

File.Delete (Server.MapPath(myRecordset("ImageUrl"))

Server.MapPath returns the physical location of the file, so the instruction translates to:

File.Delete (C:\UserUploads\SomeFile.gif")

Note: to actually process the uploaded files and save them to disk, you need some component that is capable of that. SA File Up, or ASP Upload are two good controls for uploading files.

Also, the connection string has nothing to do with this. You connect to your database like you always do (assuming you know how to do that) and all you pass is the ImageUrl and some other data about the image.

Does this help?

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Reply With Quote