naming when uploading a file

Results 1 to 2 of 2

Thread: naming when uploading a file

  1. #1
    Join Date
    Dec 1969

    Default naming when uploading a file

    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.MapPa th("upload.jpg"))<BR>Everything is named upload.jpg. How can I keep the original file name from the sender?

  2. #2
    Join Date
    Dec 1969

    Default RE: naming when uploading a file

    I don&#039;t have the help docs open in front of me, so I can&#039;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&#039;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&#039;s the Path class, sorry, don&#039;t have the docs in front of me...)<BR><BR>hth

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts