Click to See Complete Forum and Search --> : AspUpload component DB or folder?


gerjan
06-05-2003, 05:51 AM
Hello,

I'm working with the AspUpload component.
I need some advice.

explination website:
Visitors at my website can leave a message behind.
Every visitor is allowed to upload an image with his post.
The image is saved in a virtual folder on my server.

The problem is when the two different images contains the same NAME I can program two things:
- 1. The last image overwrites the first.
- 2. The name of the last image will be changed

1. In the first case I lost the first image, I don't want that.
2. In the second case I lost the name of the last image, so I won't be able to create a path to that image when I want to request that image later!

I thought when I upload the file to a DB instead of a folder I won't have this problem.
But when I does this I don't have the control to delete an image when it's expired.
I also heard there are more negatives against uploading files to a DB like Access.

My question is:
DO YOU HAVE EXPERIENCE WITH UPLOADING A FILE WITH A POST? And you have a solution for these problems or do you have other advice? PLEASE HELP!

Tnx in advange,
Gerjan :)

gerjan
06-05-2003, 08:54 AM
> If it exists, I would have a loop that continues to check for
> an existing file as I appended a sequence number to the
> name of the file. Once I found one that did not exist, I
> would then save the new file under that pre-tested unique
> name

So far I know, AspUpload automatic checks if a file exist with:
Upload.Overwrite = False

So if for example MyFile.jpg already excist he automaticly change MyFile(1).jpg, when that exist he change it into MyFile(2).jpg and so on...

The problem is that I can't control it when he change the name to 1,2,3 and so on!

I think I will add the files to a DB (since there are no other complains for that), still it would be nice to hear a solution for this problem!

cmelnick
06-05-2003, 09:18 AM
Even if you store the image in a folder on the server, there is nothing to stop you from creating your own name for the file, since it should be tied to the user's post. If you have your DB set up well, the posts should have an id of some sort that is unique. So if someone makes a post, and the autonumber (or whatever) is number 12345, why not make the uploaded image 12345.jpg. That would be an easy way to get no duplicate names, and easy to keep track of which images go with which posts.

If they are allowed to upload more than one picture with a post, then you could just do 12345_1.jpg, 12345_2.jpg etc.

That is how I did it a while back when I had made a message board.