copy file from a location variable

A

Andrew

Hi,

I want to copy a file from a variable location
"C:\...\myDocument\thisfile.txt" to a destination D:\data\
How can I do that? I tried to get the path from <input tyep=file>, but I
couldn't pass this value to the filesystemobject
Thanks for any idea.
 
A

Aaron Bertrand [MVP]

Have you already uploaded the file to C:\whatever\ on the server? Or is
that location on the client?

You can't access the client's file system directly... you will need to
upload the file to the server, and if you're doing that, just save the file
to d:\data\ (how you do this depends on the component you're using).

For information on copying/moving files, see http://www.aspfaq.com/2039
 
S

Steven Burn

<%
Dim strSource
Dim strDestination

strSource = Request.Form("file")
strDestination = Request.Form("destination")

Dim FSO
Dim Fl
Set FSO = CreateObject("scripting.filesystemobject")
Set Fl = FSO.MoveFile strSource, strDestination
Set FSO = Nothing
Set Fl = Nothing
Response.End
%>

<form name="MoveFile" method="post" enctype="multipart/form-data"
action="thisfile.asp">
<Input type="File" name="file">
<input type="submit" value="Move File">
</form>
--
Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!

Disclaimer:
I know I'm probably wrong, I just like taking part ;o)
 
A

Aaron Bertrand [MVP]

strSource = Request.Form("file")

This doesn't make much sense... input type = file is going to post a
binary/OLE object, not a string merely representing its path... did you try
your code?
 
S

Steven Burn

hehe, apologies, it was meant to be type=text not file (I'm having a bad
hair day).

--
Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!

Disclaimer:
I know I'm probably wrong, I just like taking part ;o)
 
A

Andrew

Sorry, I didn't specify that I do that at the local server, so I don't have
to upload. That means C: and D: are in the same machine. This is for
convenience only
In addition, I want to know to get the value(string) of the path
"C:\...\myDocument\thisfile.txt", whose value is also from by click on the
"Browse..." button. This value can be caught after submitting the form. Any
idea?
Thanks
 
A

Aaron Bertrand [MVP]

The Browse... button initiated by INPUT TYPE=FILE is for uploading a file,
not selecting the name of a file. You should create your own directory
browser with FileSystemObject for that functionality.

--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/
 
A

Andrew

How can I do that?

--
Andrew


Aaron Bertrand said:
The Browse... button initiated by INPUT TYPE=FILE is for uploading a file,
not selecting the name of a file. You should create your own directory
browser with FileSystemObject for that functionality.

--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/




but
 
A

Andrew

How can I do that? Thanks

--
Andrew


Aaron Bertrand said:
The Browse... button initiated by INPUT TYPE=FILE is for uploading a file,
not selecting the name of a file. You should create your own directory
browser with FileSystemObject for that functionality.

--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/




but
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,143
Messages
2,570,822
Members
47,368
Latest member
michaelsmithh

Latest Threads

Top