?
Solved

Upload a file via a web browser to the root directory

Posted on 2008-10-14
16
Medium Priority
?
269 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 6
16 Comments
 
LVL 29

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 29

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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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 29

Expert Comment

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

Author Comment

by:JodyFischer
ID: 22725730
no
0
 
LVL 29

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
 

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 29

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 29

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 29

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 1500 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

Get MySQL database support online, now!

At Percona’s web store you can order your MySQL database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
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.
Suggested Courses

770 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