Jump to content

how to 'unlink' file from a certain dir.


newrehmi

Recommended Posts

source: http://nl.php.net/manual/en/function.unlink.php

<?php
$fh = fopen('test.html', 'a');
fwrite($fh, '<h1>Hello world!</h1>');
fclose($fh);

mkdir('testdir', 0777);

unlink('test.html');
unlink('testdir');
?> 

 

YAAAAAWN... less than 5 mins of googling/copying/pasting......

source: http://nl.php.net/manual/en/function.unlink.php

<?php
$fh = fopen('test.html', 'a');
fwrite($fh, '<h1>Hello world!</h1>');
fclose($fh);

mkdir('testdir', 0777);

unlink('test.html');
unlink('testdir');
?> 

 

YAAAAAWN... less than 5 mins of googling/copying/pasting......

 

thanks Mr fast. But i dont understand those script. I want to delete (or unlink file) from another directory (other than same directory)... But, thats not like what I want.... hmm

Change "testdir" with your directory, obviously. Set a variable to the directory you want and place it in as testdir if the directory is going to be changing.

 

ahhh I already got I, anyway, thanks for the answer.

 

This is what I want.

unlink('dir/dir/dir/file.ext')

 

Just specify the full or relative path to the file.

 

<?php
// assume this script is in: c:\myproj\myscrypt.php
// we want to delete: c:\myproj\mydata\junkfile.dat

unlink( 'mydata/junkfile.dat' ); // relative
unlink( 'c:/myproj/mydata/junkfile.dat' ); // absolute

// I prefer to provide absolute paths based on a path I'm certain about
unlink( dirname( __FILE__ ) . '/mydata/junkfile.dat' );
?>

source: http://nl.php.net/manual/en/function.unlink.php

But, thats not like what I want.... hmm

 

on this php.net pages you always do have to take a look at the user comments....

they mostly make thing clearer...

But luckily the solution is already pointed out..

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.