PDA

View Full Version : Uploading Images


Thatguy2001au
10-11-2002, 03:03 AM
Hey There

I was hoping someone could perhaps give me an idea on something. I am in the process of developing a classifieds site where people can upload images with their advertisements. At the moment i am not storing the images in the actual database but instead in it's own seperate folder on the server.

The problem arises when an image with the same name as one that is already on the server gets uploaded. It overwrites the already existing file and the advertisement that previously had the other picture now shows the new one that has been uploaded.

Is there any way of avoiding this or renaming the file if it already exists without having to upload the picture into the database. I want to try and keep the size of the database as low as possible.

Any help will be much appreciated.

whammy
10-11-2002, 03:11 AM
What you probably need to use is Scripting.FileSystemObject to see if the file already exists before you overwrite it.

http://www.w3schools.com/asp/showfile.asp?filename=demo_fileexists

Hope that helps. :D

Thatguy2001au
10-11-2002, 03:19 AM
Thanks Whammy

I will have a look at it and see if i can manipulate it to work the way i want it to.

glenngv
10-11-2002, 03:56 AM
and aside from checking of existing file, (assuming your upload component is capable of saving the uploaded file to a different filename) you should have a filenaming convention of the images so that it would be unique, something like:

<advertiser's name or unique id (if you have one)><date uploaded (including time)>.jpg

a sample would be:

glenn10112002095154.jpg

Thatguy2001au
10-11-2002, 04:01 AM
Glenn

Thanks for the idea glenn. I will look into it. I'm only new to asp so i will try my best and see how it goes. The more ideas the better!