holmss Posted February 27, 2008 Report Posted February 27, 2008 (edited) 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 February 27, 2008 by holmss
Aleksejs Posted February 27, 2008 Report Posted February 27, 2008 noņem dolāra zīmi pirms funkcijas ftpdel() izsaukuma... Tobiš ftpdel($value) nevis $ftpdel($value) ;)
holmss Posted February 27, 2008 Author Report Posted February 27, 2008 (edited) 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 February 27, 2008 by holmss
Aleksejs Posted February 27, 2008 Report Posted February 27, 2008 (edited) Fu sajaucu, nevis ftpdel(), bet ftplist(). ;) A pamēģini vienkārši $value Edited February 27, 2008 by Aleksejs
holmss Posted February 27, 2008 Author Report Posted February 27, 2008 Paldies ;) $ftplist = (ftp_nlist($conn_id,"uploads")); foreach ($ftplist as $value) { ftp_delete($conn_id,$value); } Šādi viss darbojas :)
Recommended Posts