SuperLeon
asked on
File exchange between servers
Hi, I'm trying to figure out a way to copy a file from one server to another w/in my network. In my application, a user would upload a file onto my web server which would then also be uploaded a copy to another web server. I'd like to do this using ASP on the initial upload. Anyone have any ideas on how to do this or any suggestion on a good component to use?
As always, your help is greatly appreciated.
As always, your help is greatly appreciated.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
now uploading the file is not the problem.. but copying it to a share would be.. read on how to bypass permission issues:
How does FileSystemObject access files from a UNC \\share\?
IUSR_webservername on the web server trying to access the share must have access to the share. That
means IUSR_webservername must exist as a domain user (or at least a local user on the machine with the
share) WITH THE SAME PASSWORD and possessing appropriate permissions. We recommend RXW for IUSR_webservername
because some versions of FileSystemObject seem to choke on anything less.
In other words.. Create on the remote server that you want to access a local account with the same credentials
as the IUSR_WebServerName and WITH THE SAME PASSWORD (this is very important. if you don't know it you'll
have to change it on the webserver, note that the IUSR is a local account on the web server and not
a domain account ) now share the remote directory (w/o password prot) give the new IUSR on the remote
read/write permissions on the shared directory.. to test it log in to your web server using the IUSR
account and try to perform actions on the share.. if you don't get permission denied then all is ok
and you can now read/write from asp..If you mapped the share the IUSR won't see the map unless you map
it while logged to the web NT box as the IUSR, since mapping is a service.. anyways if you get some
troubles simply post them, this issue is simple to implement when you get used to it..
Good luck..
more details:
http://support.microsoft.com/support/kb/articles/Q197/9/64.ASP
another not practical way is to create the file locally and copy it using net bios commands fired from a batch that is in his turn processed from asp:
create a batch file (x.bat) :
net use x: \\computername\share password /user:usrid
copy c:\file1.txt x:\file2.txt
net use x: \delete
(password and username should be of a user that have enough rights to access the shares and perform manipulations)
now using the component aspexec (from www.serverobjects.com) create an aspexec instance and run the batch.. it will copy the file..
How does FileSystemObject access files from a UNC \\share\?
IUSR_webservername on the web server trying to access the share must have access to the share. That
means IUSR_webservername must exist as a domain user (or at least a local user on the machine with the
share) WITH THE SAME PASSWORD and possessing appropriate permissions. We recommend RXW for IUSR_webservername
because some versions of FileSystemObject seem to choke on anything less.
In other words.. Create on the remote server that you want to access a local account with the same credentials
as the IUSR_WebServerName and WITH THE SAME PASSWORD (this is very important. if you don't know it you'll
have to change it on the webserver, note that the IUSR is a local account on the web server and not
a domain account ) now share the remote directory (w/o password prot) give the new IUSR on the remote
read/write permissions on the shared directory.. to test it log in to your web server using the IUSR
account and try to perform actions on the share.. if you don't get permission denied then all is ok
and you can now read/write from asp..If you mapped the share the IUSR won't see the map unless you map
it while logged to the web NT box as the IUSR, since mapping is a service.. anyways if you get some
troubles simply post them, this issue is simple to implement when you get used to it..
Good luck..
more details:
http://support.microsoft.com/support/kb/articles/Q197/9/64.ASP
another not practical way is to create the file locally and copy it using net bios commands fired from a batch that is in his turn processed from asp:
create a batch file (x.bat) :
net use x: \\computername\share password /user:usrid
copy c:\file1.txt x:\file2.txt
net use x: \delete
(password and username should be of a user that have enough rights to access the shares and perform manipulations)
now using the component aspexec (from www.serverobjects.com) create an aspexec instance and run the batch.. it will copy the file..
ASKER
Thanks mgfranz....
Here's a quick overview of what I did.
I have two web servers: SERVERA and SERVERB.
SERVERA is where the ASP script of original file uploading is done (from a form submit). SERVERB is the server that I want to copy the files onto.
1: Map a directory on SERVERB
2: give write access to this directory to the IUSER account on SERVERA
after that the script below works:
<%
srcFile = "d:\local_directory\upload .txt"
dstFile = "//SERVERB/remote_director y/testUpl. txt"
set fso = server.createobject("scrip ting.files ystemobjec t")
fso.CopyFile srcFile, dstFile
set fso = nothing
%>
Thanks again...
Here's a quick overview of what I did.
I have two web servers: SERVERA and SERVERB.
SERVERA is where the ASP script of original file uploading is done (from a form submit). SERVERB is the server that I want to copy the files onto.
1: Map a directory on SERVERB
2: give write access to this directory to the IUSER account on SERVERA
after that the script below works:
<%
srcFile = "d:\local_directory\upload
dstFile = "//SERVERB/remote_director
set fso = server.createobject("scrip
fso.CopyFile srcFile, dstFile
set fso = nothing
%>
Thanks again...
ASKER
Thanks mgfranz....
Here's a quick overview of what I did.
I have two web servers: SERVERA and SERVERB.
SERVERA is where the ASP script of original file uploading is done (from a form submit). SERVERB is the server that I want to copy the files onto.
1: Map a directory on SERVERB
2: give write access to this directory to the IUSER account on SERVERA
after that the script below works:
<%
srcFile = "d:\local_directory\upload .txt"
dstFile = "//SERVERB/remote_director y/testUpl. txt"
set fso = server.createobject("scrip ting.files ystemobjec t")
fso.CopyFile srcFile, dstFile
set fso = nothing
%>
Thanks again...
Here's a quick overview of what I did.
I have two web servers: SERVERA and SERVERB.
SERVERA is where the ASP script of original file uploading is done (from a form submit). SERVERB is the server that I want to copy the files onto.
1: Map a directory on SERVERB
2: give write access to this directory to the IUSER account on SERVERA
after that the script below works:
<%
srcFile = "d:\local_directory\upload
dstFile = "//SERVERB/remote_director
set fso = server.createobject("scrip
fso.CopyFile srcFile, dstFile
set fso = nothing
%>
Thanks again...
ASKER
actually, I lied a little. my users will always be logged into my company's intranet so they assume the generic user account for the intranet once they have logged in. so, all we had to do was give that generic user account permissions to the share we set up.
Yes, permissions will be necessary on the remote server.
http://asphole.aspin.com/func/review?tree=aspin/components/file/upload&id=1456410&cob=ASPhole
Simply set the permission of the component to have read/write access to the servers and you should be set. The component has a built in copy command that you can use to upload the same file to another web server.
This component is free and the documentation can be found in the company's website. It is very detailed and easy to use.
Enjoy and have fun!