Jump to content

Data Synchronisation between a local xml file and my web server

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
7 replies to this topic

#1
rendy.dev

rendy.dev

    Newbie

  • Members
  • Pip
  • 4 posts
Hi,

I need help with a project I am working on. I need to upload/read an xml from a local drive of any platform (linux, windows, mac) and synchronize it with my web server, which will then update my DB. Local xml file path is predefined and stored in my DB. This is part 1.

Part 2, I will have to update the sync(ed) xml and replace the file on my local drive.

Part 1 and part 2 will execute in sequence when the user click on a "Sync" button after logged in.

Here is what I plan to use, PHP, MySQL, Javascript.

What I know so far.
1. Due to security reasons we cannot dynamically update the value of the input file type. So setting the known file location is not possible.

I will like to know if there is anyway we can upload/read & overwrite a xml file without any middleware like adobe air that needs to be pre-installed to any of the platform to achieve what I plan to do?

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
I'm not clear on where PHP, JavaScript, or Adobe Air come into this. At the most, PHP should be enough.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
rendy.dev

rendy.dev

    Newbie

  • Members
  • Pip
  • 4 posts
Nice! So how do I go about using PHP?

WingedPanther said:

I'm not clear on where PHP, JavaScript, or Adobe Air come into this. At the most, PHP should be enough.


#4
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
1) learn PHP. It's usually used to power web-apps but can be used in other ways.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#5
James.H

James.H

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 866 posts
Check out the tutorial section on PHP to start learning:

PHP Tutorials - CodeCall Programming Forum

#6
rendy.dev

rendy.dev

    Newbie

  • Members
  • Pip
  • 4 posts
Dear All,

I tried using PHP but it does not allow me to preset the file I want to upload to the web server. I am working on a social portal that sync data between a portal device via a USB.
<?php
$ftp_server = "localhost";
$ftp_user_name = "rendy";
$ftp_user_pass = "devdev";

// open some file for reading
$dfile = 'test.php';
$file = 'E:\\test.php';
$fp = fopen($file, 'r');

// set up basic connection
$conn_id = ftp_connect($ftp_server);

// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);

// check connection
if ((!$conn_id) || (!$login_result)) {
	echo "FTP connection has failed!";
	echo "Attempted to connect to $ftp_server for user $ftp_user_name";
	exit;
} else {
	echo "Connected to $ftp_server, for user $ftp_user_name";
}

// upload the file
$upload = ftp_fput($conn_id, $dfile, $fp, FTP_ASCII);

// check upload status
if (!$upload) {
	echo "FTP upload has failed!";
} else {
	echo "Uploaded $source_file to $ftp_server as $destination_file";
}

// close the FTP stream
ftp_close($conn_id);
?>

<?php
$ftp_server = "localhost";
$ftp_user_name = "rendy";
$ftp_user_pass = "devdev";
$source_file = "E:\\test.php";
$destination_file = "test.php";

// set up basic connection
$conn_id = ftp_connect($ftp_server);

// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);

// check connection
if ((!$conn_id) || (!$login_result)) {
	echo "FTP connection has failed!";
	echo "Attempted to connect to $ftp_server for user $ftp_user_name";
	exit;
} else {
	echo "Connected to $ftp_server, for user $ftp_user_name";
}

// upload the file
$upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);

// check upload status
if (!$upload) {
	echo "FTP upload has failed!";
} else {
	echo "Uploaded $source_file to $ftp_server as $destination_file";
}

// close the FTP stream
ftp_close($conn_id);
?>

Edited by WingedPanther, 13 January 2010 - 05:56 PM.
add php tags


#7
rendy.dev

rendy.dev

    Newbie

  • Members
  • Pip
  • 4 posts
Note the last post consist of 2 php codes if you noticed :)

#8
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
Next time, please use PHP tags.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog