<?php

$ftp_server = "ftp.lci.in";

$ftp_user_name = "aandroidp";

$ftp_user_pass = "C!99SmSmM";



try 

	{

		$dbh = new PDO("sqlite:./test11");

		echo "Handle has been created ...... <br><br>";

	}

	catch(PDOException $e)

	{

		echo $e->getMessage();

		echo "<br><br>Database -- NOT -- loaded successfully .. ";

		die( "<br><br>Query Closed !!! $error");

	}

	$sql = "SELECT * FROM image_path where img_flag='false'";

	echo $sql;

	$rs = $dbh->query($sql);

	if($sql) {echo"image_path with false <br>";}

	echo "hi";

	$rs->setFetchMode(PDO::FETCH_ASSOC);

	echo "hi";

	while ($row = $rs->fetch()) 

	{echo "hi";

		$img_path = $row["img_path"];

		$img = explode('\\',$img_path);

		

		

$destination_file = '/images/'.$img[2];

$source_file = 'C:/smart survey/imgs/'.$img[2];



// 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);  // line 30



// 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);

	$flag = "true";

	$sql = "UPDATE image_path

		SET img_flag=?

		WHERE pic_id=?";

		$q = $dbh->prepare($sql);

		$q->execute(array($flag,$pic_id));

		if($q){echo "update image_path success<br>";}

	}

?>



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Untitled Document</title>

</head>



<body>



</body>

</html>