Changing a File remotly
Moderator: General Moderators
- patelhiteshp
- Forum Newbie
- Posts: 9
- Joined: Tue Jul 03, 2007 7:02 am
Changing a File remotly
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
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
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.
http://php.net/manual/en/ref.ftp.php
Read the remote file, change what you want and upload it back.
- patelhiteshp
- Forum Newbie
- Posts: 9
- Joined: Tue Jul 03, 2007 7:02 am
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.
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.
Step 1) makes it possible.That can be the solution only if the Physical copy of the file and the Website is on the same server.
ftp is the way to go
i agree , in ftp will be really simple to do
- patelhiteshp
- Forum Newbie
- Posts: 9
- Joined: Tue Jul 03, 2007 7:02 am
- patelhiteshp
- Forum Newbie
- Posts: 9
- Joined: Tue Jul 03, 2007 7:02 am
Changing a File remotly
feyd | Please use
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]