Hi all, I want to upload the file into a folder called "Uploadfile" rather than putting the file everywhere on the server, how to change the following code. Thanks.
If you want to put the files within the website root then you would use server.mappath website root File1.PostedFile.SaveAs(Server.MapPath("\") + StrFileName); files folder File1.PostedFile.SaveAs(Server.MapPath("\files\") + StrFileName); If you want to save outside of the root then you will have to specify the full path to the location.
Thanks, Now i can upload the file by following the code: But i have a another porblem, how to Download the "Uploadfile" with different directory. Code here only can access the "Upload file" in same directory(folder)? Plz help me
I try to use following code to access the file in different directory but on the same server. It shows "The resource cannot be found". . What probelm the code has?
this site had tons of free code snippets and examples for uploading, or ftping: http://www.codeproject.com/ requires a registration to download - but is very worth it!
you can always get the current script root using the ~ sign and then use the Server.MapPath('your directory') will get the correct path for the server then use it to upload.