Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (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 by Robby
Hobbes...
  • *Experts*
Posted

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\"

"Being grown up isn't half as fun as growing up

These are the best days of our lives"

-The Ataris, In This Diary

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...