JodyFischer
asked on
Upload a file via a web browser to the root directory
If I want to upload a file to a spefic directory (lets say uploads) the following code works perfectly
' Grab the file name
FileName = Upload.Fields("File1").Fil eName
' Get path to save file to
Folder = Server.MapPath("Uploads") & "\"
' Save the binary data to the file system
Upload("File1").SaveAs Folder & FileName
' Release upload object from memory
Set Upload = Nothing
How do you do it if you want the file in the root directory?
' Grab the file name
FileName = Upload.Fields("File1").Fil
' Get path to save file to
Folder = Server.MapPath("Uploads") & "\"
' Save the binary data to the file system
Upload("File1").SaveAs Folder & FileName
' Release upload object from memory
Set Upload = Nothing
How do you do it if you want the file in the root directory?
ASKER
I don't understand what you are saying.
sorry - what I mean is I would try the following code:
....................
Dim fs, folder
Set fs = CreateObject("Scripting.Fi leSystemOb ject")
Set folder = fs.GetFolder("/")
....................
and the code has to reside in the root directory
....................
Dim fs, folder
Set fs = CreateObject("Scripting.Fi
Set folder = fs.GetFolder("/")
....................
and the code has to reside in the root directory
ASKER
Sorry for not understanding, but where would it go within this code?
Grab the file name
FileName = Upload.Fields("File1").Fil eName
' Get path to save file to
Folder = Server.MapPath("Uploads") & "\"
' Save the binary data to the file system
Upload("File1").SaveAs Folder & FileName
' Release upload object from memory
Set Upload = Nothing
Grab the file name
FileName = Upload.Fields("File1").Fil
' Get path to save file to
Folder = Server.MapPath("Uploads") & "\"
' Save the binary data to the file system
Upload("File1").SaveAs Folder & FileName
' Release upload object from memory
Set Upload = Nothing
did you write this code?
ASKER
no
it would be easier to use code the already works, than to bodge something written some time ago.
see : http://www.freeaspupload.net/
its free and r4esady to integrate into your web pages.
I use code from dmxzone.com
see : http://www.freeaspupload.net/
its free and r4esady to integrate into your web pages.
I use code from dmxzone.com
ASKER
The code above works perfectly in a sub folder. I just need to know how to make it go into the root directory. Can you help me with this or point me to someone who can?
use this:
' Grab the file name
FileName = Upload.Fields("File1").Fil eName
' Get path to save file to
Folder = Server.MapPath("\")
' Save the binary data to the file system
Upload("File1").SaveAs Folder & FileName
' Release upload object from memory
Set Upload = Nothing
-----------the code has to be in the root folder.--------------
' Grab the file name
FileName = Upload.Fields("File1").Fil
' Get path to save file to
Folder = Server.MapPath("\")
' Save the binary data to the file system
Upload("File1").SaveAs Folder & FileName
' Release upload object from memory
Set Upload = Nothing
-----------the code has to be in the root folder.--------------
ASKER
Tried it but it didn;t work.
where did it upload the file?
ASKER
it didn't. nothing happened
can you post more of the code you used for this ?
I'll asked some others to come and help.
I'll asked some others to come and help.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Dim fs, folder
Set fs = CreateObject("Scripting.Fi
Set folder = fs.GetFolder("/")
or is it
Set folder = fs.GetFolder(".")
and the code has to reside in the root directory