Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

file upload location 1

Status
Not open for further replies.

mattbold

Programmer
Oct 5, 2001
45
0
0
GB
hello,

i read some other posts about uploading files and found the resource on the O'Reilly site very useful, and uploading files is working fine when i have:

Dim savePath As String = "C:\temp\"

But how do i go about storing the uploaded file in a directory relative to where the aspx files are stored? i've been fiddling around with the savepath changing it to things like "DJs\" and "\DJs\", but to no avail...

any help would be much appreciated!

- matt
 
matt: Here's a path routine that I use in an upload photo page; perhas there's a hint there for you.

Dim sPath as String
Dim sFile as String
Dim sFullPath as String
Dim sSplit() as String
Dim sPathFriendly as String

'Upload to same path as script
'Internet Anonymous User must have write permissions

sPath = Server.MapPath(".\Photos")
If Right(sPath, 1) <> &quot;\&quot; then
sPathFriendly = sPath 'Friendly path name for display
sPath = sPath & &quot;\&quot;
Else
sPathFriendly = Left(sPath, Len(sPath) - 1)
End If

'Save as same file name being posted
'The code below resolves the file name
'(removes path info)
sFile = txtUpload.PostedFile.FileName
sSplit = Split(sFile, &quot;\&quot;)
sFile = sSplit(Ubound(sSplit))
sFullPath = sPath & sFile
Try
....

Let me know if this helps.
 
cheers man, is working marvellously now (as far as i'm aware!) it was the Server.MapPath that was missing... :)

- matt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top