I'm developing a plugin which getting data as CSV file. Then i should upload the images from an other server to my server using the details of this CSV file. The problem is the coding which is not in my Wordpress file is working. But when i put the same file i to the Wordpress plugin folder, then it create only the csv file, but it doesn't upload the images from the other server to my server. Below is the coding that i use for it.(I gave all the file permission 777).
$handle = fopen('agentListing.csv', 'r');
$row = fgetcsv($handle);
while (($row = fgetcsv($handle)) !== false)
{
print '$row[130]--->'.$row[130].'<br>';
$dir = substr($row[130], -3);
$fileno = $row[130];
$ftpup = "./photos/";
$local_file ="./photos/{$fileno}.jpg";
$server_file = "/mlsmultiphotos/1/{$dir}/{$fileno}.jpg";
// set up basic connection
$conn_id = ftp_connect('3pv.torontomls.net') or die("Couldn't connect to $ftp_server");
// login with username and password
$login_result = ftp_login($conn_id, 'user@photos', 'Password');
exec('touch {$local_file}');
if (ftp_get($conn_id, $local_file, $server_file, FTP_BINARY)) {
echo "Successfully written to $local_file\n";
} else {
echo "There was a problem\n";
}
}