Hobbes Posted June 20, 2003 Posted June 20, 2003 (edited) I am trying to upload an image to a targeted folder. (i.e. C:\Inetpub\wwwroot\Store\images\) But my file upload page is in another folder. (i.e. C:\Inetpub\wwwroot\Store\admin\) I use the following code: Dim strFilePath As String strFilePath = System.IO.Path.GetDirectoryName(Server.MapPath("uploadFile.aspx")) uploadFilePath.PostedFile.SaveAs((strFilePath & "\" & "images" & "\" & txtFileName.Value)) lblTitle.InnerHtml = "File uploaded successfully" lblMessage.InnerHtml = "Your file was uploaded successfully to <br>" & _ "<b>" & strFilePath & "\" & _ txtFileName.Value & "</b><br>on the Web server." HideFileUploadControls() HideUserAuthenticationControls() lblMessage.Visible = True btnReUpload.Visible = True HyperLink1.NavigateUrl = "http://localhost/store/images/" & txtFileName.Value HyperLink1.Visible = True The thing is that using System.IO.Path.GetDirectoryName(Server.MapPath("uploadFile.aspx")) I am uploading it to "C:\Inetpub\wwwroot\Store\admin\" Any one have any idea to load it into my desired folder?? Thanks :) Edited June 20, 2003 by Robby Quote Hobbes...
*Experts* Bucky Posted June 20, 2003 *Experts* Posted June 20, 2003 Append a ".." to the file name, and it will be smart enough to back up one directory, like so: "C:\Inetpub\wwwroot\Store\admin\..\images\" Quote "Being grown up isn't half as fun as growing up These are the best days of our lives" -The Ataris, In This Diary
Hobbes Posted June 21, 2003 Author Posted June 21, 2003 Thank you!! :) Problem solve!! Quote Hobbes...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.