Solved

Upload a file via a web browser to the root directory

Posted on 2008-10-14
16
263 Views
Last Modified: 2010-04-06
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").FileName

' 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?
0
Comment
Question by:JodyFischer
  • 7
  • 6
16 Comments
 
LVL 28

Expert Comment

by:chilternPC
ID: 22716575
I utry..
Dim fs, folder
     
   Set fs = CreateObject("Scripting.FileSystemObject")
     Set folder = fs.GetFolder("/")

or is it

Set folder = fs.GetFolder(".")


and the code has to reside in the root directory
0
 

Author Comment

by:JodyFischer
ID: 22721977
I don't understand what you are saying.
0
 
LVL 28

Expert Comment

by:chilternPC
ID: 22723373
sorry - what I mean is I would try the following code:
....................
Dim fs, folder
  Set fs = CreateObject("Scripting.FileSystemObject")
   Set folder = fs.GetFolder("/")
....................
and the code has to reside in the root directory
0
 

Author Comment

by:JodyFischer
ID: 22725216
Sorry for not understanding, but where would it go within this code?

 Grab the file name
FileName = Upload.Fields("File1").FileName

' 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
0
 
LVL 28

Expert Comment

by:chilternPC
ID: 22725596
did you write this code?
0
 

Author Comment

by:JodyFischer
ID: 22725730
no
0
 
LVL 28

Expert Comment

by:chilternPC
ID: 22726028
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

0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

Author Comment

by:JodyFischer
ID: 22728407
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?
0
 
LVL 28

Expert Comment

by:chilternPC
ID: 22728565
use this:

' Grab the file name
FileName = Upload.Fields("File1").FileName

' 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.--------------
0
 

Author Comment

by:JodyFischer
ID: 22731496
Tried it but it didn;t work.
0
 
LVL 28

Expert Comment

by:chilternPC
ID: 22732606
where did it upload the file?
0
 

Author Comment

by:JodyFischer
ID: 22733569
it didn't. nothing happened
0
 
LVL 28

Expert Comment

by:chilternPC
ID: 22734527
can you post more of the code you used for this ?
I'll asked some others to come and help.
0
 
LVL 20

Accepted Solution

by:
Gawai earned 500 total points
ID: 22743214
Hi Jody,

change
Folder = Server.MapPath("Uploads") & "\"

to
Folder = Server.MapPath("/")
or
Folder = Server.MapPath("\") & "\"

for more info about Server.MapPath() refer
http://www.w3schools.com/ASP/met_mappath.asp

0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This video teaches users how to migrate an existing Wordpress website to a new domain.
Learn how to set-up PayPal payment integration in your Wufoo form. Allow your users to remit payment through PayPal upon completion of your online form. This is helpful for collecting membership payments, customer payments, donations, and more.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now