Jump to content
php.lv forumi

PHP -> FTP list/delete


holmss
 Share

Recommended Posts

Ir kļūda pie failu dzēšanas, list f-ja darbojas, taču delete ne. Saliku visu kopā, lai gan dzīvē viss ir nodalīts. kā vajadzētu realizēt ftp_delete, lai viss darbotos?

 

<?php

// connect to server
$ftp_server = "";  //address of ftp server.
$ftp_user_name = ""; // Username
$ftp_user_pass = "";   // Password

//šī daļa ir vienāda, gan list, gan delete	

$conn_id = ftp_connect($ftp_server); // set up connection
  $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass) or die("<h2>You do not have access to this ftp server!</h2>");
  if ((!$conn_id) || (!$login_result)) {  // check connection
		 echo "FTP connection has failed! <br />";
		 echo "Attempted to connect to $ftp_server for user $ftp_user_name";
		 exit;
	 } else {
			   echo "Connected";
		}
// list files	- viss darbojas
	ftp_pasv ( $conn_id, true ); //pasive mode
	$ftplist = (ftp_nlist($conn_id,"uploads")); //list files 	
	foreach ($ftplist as $value)
	{
		echo "Value: $value<br />\n";
	}

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

//delete files - šī daļa nestrādā 
	ftp_pasv ( $conn_id, true );//pasive mode
	$ftplist = (ftp_nlist($conn_id,"uploads"));


	foreach ($ftplist as $value)
	{
		ftp_delete($conn_id,$ftplist($value)); //Fatal error: Function name must be a string in C:\xampp\htdocs\work\delete.php on line (šajā līnijā)
	}

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

?>

 

Jau iepriekš paldies :)

Edited by holmss
Link to comment
Share on other sites

Fatal error: Call to undefined function ftpdel() in C:\xampp\htdocs\work\delete.php

 

Nebūs īstais :(

 

Pag, atradu vienu kļūdu, ko izlaboju, bet rezultāts nemainās.

orģinālajā kļūda: Fatal error: Function name must be a string in C:\xampp\htdocs\work\delete.php

un bez $: Fatal error: Call to undefined function ftpdel() in C:\xampp\htdocs\work\delete.php

Edited by holmss
Link to comment
Share on other sites

 Share

×
×
  • Create New...