Page 1 of 1

Changing a File remotly

Posted: Mon Jul 30, 2007 2:37 am
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

Posted: Mon Jul 30, 2007 4:35 am
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.

Posted: Mon Jul 30, 2007 4:43 am
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.

Posted: Mon Jul 30, 2007 5:33 am
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.

ftp is the way to go

Posted: Mon Jul 30, 2007 6:17 am
by yacahuma
i agree , in ftp will be really simple to do

Posted: Mon Jul 30, 2007 6:41 am
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?

Posted: Mon Jul 30, 2007 6:53 am
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.

Changing a File remotly

Posted: Fri Aug 03, 2007 2:04 am
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]