naming when uploading a file

Chilster69

New Member
Im working on a page that will allow a file to be uploaded. Everything appears to be working but I dont know how to keep the same file name. With the following code:<BR>UploadFile.PostedFile.SaveAs(Server.MapPath("upload.jpg"))<BR>Everything is named upload.jpg. How can I keep the original file name from the sender?I don't have the help docs open in front of me, so I can't recall the exact syntax, but the PostedFile class contains a property that shows the complete filename of the uploaded component. You can then use the Path class's GetFilename method to get just the filename.<BR><BR>Alternatively, if you need a unique name for every upload you can generate a random file name... I believe the Environment class contains a GetTempFilename method (or maybe it's the Path class, sorry, don't have the docs in front of me...)<BR><BR>hth
 
Back
Top