Jump to content

Unlink file


retoto

Recommended Posts

Hi nice ppl :P

i try to delete file with php

with that code

 

<?php

$file = "test.txt";

if (unlink($file)) {

  echo ("Deleted $file");

  } else {

  echo ("cant Deleted $file");

  }

?>

i give CHMOD 777

and still that dont delete the file :\

 

some one know why :\ ??

Link to comment
Share on other sites

Okay..

you may need to change the access right of the public_html, do you know what they are set to ?

or the server may have some restrictions..

 

i guess you could try via FTP....

<?php
$file = "test.txt";
$ftpUserName = 'username';
$ftpUserPass = 'userpass';
$ftpServer = 'ftp.example.com';

  $ftpConn = ftp_connect($ftpServer);

  if (!$ftpConn) {
    die("Unable to connect to $ftpServer");
  }

if (@ftp_login($conn_id, $ftpUserName, $ftpUserPass)) {
   echo "Connected as $ftpUserName @ $ftpServer";
}
else {
   echo "Couldn't connect as $ftpUserName";
   ftp_close($ftpConn);
   die("Closed connection to $ftpServer");
}

echo ftp_chmod($ftpConn, 0777, $file) ? "CHMOD successful!" : 'Error';

// try to delete $file
if (ftp_delete($ftpConn, $file)) {
echo "$file deleted successful\n";
} else {
echo "could not delete $file\n";
}

// Close the connection
ftp_close($conn_id);
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.