Page 1 of 1

error, need help

Posted: Mon Nov 24, 2008 8:07 am
by asifkamalzahid
how to delete some file from ftp server,
i access the file on the server, but on deletion it give mee the error,

acess denied to delete the file

Re: error, need help

Posted: Mon Nov 24, 2008 8:19 am
by aceconcepts
Use unlink(). But you need directory permission.

Re: error, need help

Posted: Mon Nov 24, 2008 9:27 am
by asifkamalzahid
i am sending this code , can you tell me how to use unlike(),
i can create and delete directory on my FTP server by using mouse, but i dont know either i need separate access permission by using php query.



i hav the following error in code

Warning: ftp_delete() [function.ftp-delete]: Access is denied. in G:\WEBROOT\wilbourn\ftptest\uploadfunctionpage.php on line 35
could not delete t.DOC

Code: Select all

 
 
 
<?php 
 
//Move or Upload Folder Using PHP FTP Functions
function moveFolder($_server, $_user_name, $_user_pass, $local_dir, $remote_dir) {
 
echo"$_user_name <br/>";
echo"$_user_pass <br/>";
echo" directories are : <br/>";
echo"$local_dir<br/>";
echo"$remote_dir <br/>";
 
 
 
// set up basic connection
$_conn_id = ftp_connect($_server);
 
// login with username and password
$_login_result = ftp_login($_conn_id, $_user_name, $_user_pass);
 
// check connection
if ((!$_conn_id) || (!$_login_result)) {
$_error = "FTP connection has failed!";
$_error .= "Attempted to connect to $_server for user $_user_name";
$result = false;
} else {
$_error = "Connected to $_server, for user $_user_name";
}
 
$conn_id = $_conn_id;
 
$file = 't.DOC';
echo "Current directory: " . ftp_pwd($conn_id) . "\n";
echo "<br/>";
 
 
echo "<br/>";
if (ftp_chdir($conn_id, "$remote_dir")) {
 
echo "Current directory is now After changes: " . ftp_pwd($conn_id) . "\n";
    
echo "<br/>";   echo "<br/>";   echo "<br/>";   
    
// try to delete $file
if (ftp_delete($conn_id, $file)) {
 echo "$file deleted successful\n";
} else {
 echo "could not delete $file\n";
}   
 
 
 
    
// get the file list for    
$buff = ftp_rawlist($conn_id, ".");
echo "<br/>";   
var_dump($buff);
 
}
 else { 
    echo "Couldn't change directory\n";
}
 
 
ftp_close($conn_id);
 
}
 
?
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Re: error, need help

Posted: Mon Nov 24, 2008 9:35 am
by aceconcepts
Always consult the PHP manual if in doubt: http://uk2.php.net/unlink

Re: error, need help

Posted: Mon Nov 24, 2008 9:36 am
by asifkamalzahid
i checked but still confused how to use in my code

Re: error, need help

Posted: Mon Nov 24, 2008 9:37 am
by aceconcepts
They have lots of examples and it is rather straight forward.

I'm not going to do your work for you.

Re: error, need help

Posted: Mon Nov 24, 2008 9:38 am
by asifkamalzahid
why i need to use unlike and where i need to use.
i realy dont know about this fuction. what is basically it doing?

Re: error, need help

Posted: Mon Nov 24, 2008 9:39 am
by asifkamalzahid
sir
if u not intersted then please please dont reply many thanks

Re: error, need help

Posted: Mon Nov 24, 2008 9:47 am
by aceconcepts
I'm interested in helping people who are interested in helping themselves.

Don't get all weird about it. I've noticed you submit multiple posts quite often - it's just annoying!

Re: error, need help

Posted: Mon Nov 24, 2008 9:53 am
by asifkamalzahid
i will not send any mulitiple post again ,but they were two different probloms i had,
Anyway thanks for your advoice and help.

Re: error, need help

Posted: Mon Nov 24, 2008 10:50 am
by asifkamalzahid
solved
there was problom with my folder permission rights,

Re: error, need help

Posted: Mon Nov 24, 2008 10:51 am
by aceconcepts
aceconcepts wrote:Use unlink(). But you need directory permission.