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?
Data Synchronisation between a local xml file and my web server
Started by rendy.dev, Jan 11 2010 12:45 AM
7 replies to this topic
#1
Posted 11 January 2010 - 12:45 AM
|
|
|
#2
Posted 11 January 2010 - 09:07 AM
I'm not clear on where PHP, JavaScript, or Adobe Air come into this. At the most, PHP should be enough.
#3
Posted 11 January 2010 - 06:08 PM
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
Posted 12 January 2010 - 09:05 AM
1) learn PHP. It's usually used to power web-apps but can be used in other ways.
#5
Posted 12 January 2010 - 11:12 AM
#6
Posted 12 January 2010 - 08:51 PM
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.
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
Posted 12 January 2010 - 08:54 PM
Note the last post consist of 2 php codes if you noticed :)
#8
Posted 13 January 2010 - 05:56 PM
Next time, please use PHP tags.


Sign In
Create Account

Back to top









