Changing a File remotly

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
patelhiteshp
Forum Newbie
Posts: 9
Joined: Tue Jul 03, 2007 7:02 am

Changing a File remotly

Post by patelhiteshp »

Programmers,

I have a problem regarding accessing a file remotly.
Can someone help me in that?


I'll explain my problem thru example.

Example :

My website is @ http://95.165.168.168/newsite/ this URL.
The file which I wanted to access is @ 92.168.165.153 this machine in c://reservation/new.xml location.


As you can see
1. My reservation file is on another machine
2. My webapplication is on another server.

Now I want my website / webapplication to change the file which is @
92.168.165.153 server. I have the Admin login information ie. username and password
of the this machine. I can able to connect 92.168.165.153 machin thru php FTP code, but
I can not able to change the file containts.

Can any one suggest me how can I achive this using php code.

Hitesh
miro_igov
Forum Contributor
Posts: 485
Joined: Fri Mar 31, 2006 5:06 am
Location: Bulgaria

Post by miro_igov »

You can do it with the FTP.

http://php.net/manual/en/ref.ftp.php

Read the remote file, change what you want and upload it back.
User avatar
patelhiteshp
Forum Newbie
Posts: 9
Joined: Tue Jul 03, 2007 7:02 am

Post by patelhiteshp »

That can be the solution only if the Physical copy of the file and the Website is on the same server.
Or else its not the solution for my problem.
miro_igov
Forum Contributor
Posts: 485
Joined: Fri Mar 31, 2006 5:06 am
Location: Bulgaria

Post by miro_igov »

I'm not with you.

How about 1) downloading the reservation file from the remote machine by FTP, 2)edit is as you want on your WEB app server, 3)upload it back to the remote machine via FTP.
That can be the solution only if the Physical copy of the file and the Website is on the same server.
Step 1) makes it possible.
User avatar
yacahuma
Forum Regular
Posts: 870
Joined: Sun Jul 01, 2007 7:11 am

ftp is the way to go

Post by yacahuma »

i agree , in ftp will be really simple to do
User avatar
patelhiteshp
Forum Newbie
Posts: 9
Joined: Tue Jul 03, 2007 7:02 am

Post by patelhiteshp »

That will take a looooooooooooooooooong time

That is not at all feasible, coz we have almost 10 file in a min in season.

Can't work?
miro_igov
Forum Contributor
Posts: 485
Joined: Fri Mar 31, 2006 5:06 am
Location: Bulgaria

Post by miro_igov »

You can't have write permissions on remote machine files with the http anyway. But you can develop a web service on the remote machine if you have permissions.
User avatar
patelhiteshp
Forum Newbie
Posts: 9
Joined: Tue Jul 03, 2007 7:02 am

Changing a File remotly

Post by patelhiteshp »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: :arrow: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


I changed the file name Successfully with FTP code only
Now i need to Download a server's file on local machine.....

I have attached code of this below....

Code: Select all

<?php
echo "<br>--------------------------------Connecting
    $ftp_server = "192.168.1.14"; // Server Where the Original File resides
    $ftp_user_name = "username";
    $ftp_user_pass = "pw";
    $conn_id = ftp_connect($ftp_server) or die("Could not Connect To 192.168.1.134");
    if($conn_id)
        echo "<br>Successfully FTP Connect With 192.168.1.14";        
    
    $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass) or die("<br>Login Problem : ");
    if($login_result)
        echo "<br>Successfully FTP Login in 192.168.1.14";

       $local_fileget = "h_get.txt"; // In FTP file Folder on Local Machine
    $server_fileget = "/test/h_stop.txt"; // File Position in Server - FTP folder
    
    if (ftp_get($conn, $local_fileget, $server_fileget,FTP_ASCII)) //  ftp_gets not working
    {
        echo "<br><br>Successfully GET to $local_fileget To make Changes\n";
    }
    else
    {
        echo "<br><br>There was a problem while Getting the File to Local machine\n";
    }
        
        // Close the connection
    ftp_close($conn_id);

?>

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: :arrow: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Post Reply