?
Solved

move_uploaded_file from server to server

Posted on 2006-04-13
16
Medium Priority
?
300 Views
Last Modified: 2013-12-13
We would like to utlize the Move_Upload_File to get a file to another
web server.  We are currently using Windows Server 2003 with PHP on
them.  However I am sure I have a file permission issue on the
targetted server box (since its going from one box to another), but I
am not sure how to force PHP to use a specific user (since its a subset
of IIS, it almost looks like it uses Anonymous - which will not work
for the scenerio I am looking at that I am aware of).

Any Help would be appreciated - here is a snipet of our code:


move_uploaded_file($_FILES['upload']['tmp_name'],"\\server2\share\directory­\$filename")

0
Comment
Question by:gregsopcak
  • 6
  • 3
  • 3
  • +1
13 Comments
 
LVL 4

Accepted Solution

by:
AndyAelbrecht earned 500 total points
ID: 16449510
it is using the IISR_USR (or something very similar) as user.
if you want it to be able to access a share with a password, you have 2 choices:
either run PHP cgi as another user who does have access (i don't know how, though)
or
give the share write permissions for the IISR_USR user (which is imho, way more secure, especially if you only give him file creation rights; this way this user can never overwrite files there or even read them)
0
 
LVL 12

Expert Comment

by:str_kani
ID: 16469317
I would move it to the other server using ftp, that will be better and safe in my view.
0
 

Author Comment

by:gregsopcak
ID: 16469739
What are the FTP commands in PHP?

Thanks!
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 40

Expert Comment

by:Richard Quadling
ID: 16475733
It makes little difference HOW you move the files between servers. As long as you have permissions, you can do it.

You COULD simply allow everyone access to the share!

As far as using FTP, you will need to have an FTP server running on the second server. There is no point in using FTP to do this.

You don't need it. Just get the permissions right. Try asking the permissions question in the IIS section http://www.experts-exchange.com/Web/Web_Servers/IIS

0
 
LVL 4

Expert Comment

by:AndyAelbrecht
ID: 16476102
i have to stress how much I agree with RQuadling here and not with str_kani (sorry mate).

setting up an ftp server (which uses plain text passwords) to upload stuff to a directory that's already available on a local share is overkill and not needed. NTFS authentication is alot safer.

setting up an ftp server is just too much of a hassle, get the permissions on the folder right and you're done :-)
0
 
LVL 40

Expert Comment

by:Richard Quadling
ID: 16476161
Is your PHP fully active? Are you running safe mode or restricted directory usage?

There are many securities within PHP which could also stop you accessing the files.

0
 

Author Comment

by:gregsopcak
ID: 16490404
I did do an FTP and it worked great.. but I would still be interested in using the NTFS.. However its aniling down what user PHP is using to access it... I am not able to grasp it as its not a "service" but runs from IIS...

I am running in normal PHP in ISAPI mode... Its a precompiled version (I didnt compile it - downloaded it from php.net)
0
 
LVL 4

Expert Comment

by:AndyAelbrecht
ID: 16495418
hey gregsopcak,

like i said in my first comment, the user that IIS runs under is the "IISR_USR" or something very similar.
just look thru your local users (on the server that is running the IIS) and you will find this user pretty fast.

give this user the proper NTFS rights on the share you want to access ! :)
0
 
LVL 40

Expert Comment

by:Richard Quadling
ID: 16495577
A daft way to find the IIS user is to create a directory with everyone having full rights.

Then use PHP to create a file in that directory.

Then check the owner.

I'm sure there are other ways, but with different versions of IIS the user changed.


You should be able to check the IIS service account within Control Panel -> Services. It probably will NOT be LocalSystem or NetworkService, but something else.

0
 

Author Comment

by:gregsopcak
ID: 16501779
I setup a copy of the IUSR on the other server and give it file rights to the share and etc, however its still not working...

As far as the IIS Admin Service account is setup as Local System I believe, not the IUSR user.. should I change that to be that IUSR on the server sending so hopefully it uses that?
0
 
LVL 40

Assisted Solution

by:Richard Quadling
Richard Quadling earned 500 total points
ID: 16505183
I think the IIS service is WWW Publishing or something like that? IIS Admin Service is a service to administer IIS which would only need local rights.

It may be better to ask this question (or at least put a pointer question) in the IIS section here on EE.
0
 
LVL 40

Expert Comment

by:Richard Quadling
ID: 16505196
Ah. It MAY be something like ...

DOMAIN\IWAM_SERVER or DOMAIN\IUSR_SERVER

So, say your domain is COUNTDOWN and the webserver is WWW, then try ...

COUNTDOWN\IWAM_WWW or COUNTDOWN\IUSR_WWW

0
 
LVL 40

Expert Comment

by:Richard Quadling
ID: 16706729
Split
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

850 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