|
<?php
|
|
|
$filename = 'mango.jpg';
|
assigned the name of the file
|
|
if (@unlink($filename)){
|
deleted the file , if file deleted yes
|
|
echo 'file <strong>' .$filename.' </strong>has beenn
deleted;
|
print file is deleted
|
|
} else {
|
if not
|
|
if (@file_exists ($filename)){
|
checks file is there or not if file is ther prints 1
|
|
echo 'file <strong.' .$filename. '</strong> exists but
cannot be deleted!'
|
file is there
|
|
} else {
|
|
|
echo 'file <strong> '.$filename.' </strong> does not
exist!';
|
if file is not there, does not exists
|
|
}
|
|
|
}
|
|
|
?>
|
|
|
rename the file name
|
|
|
<?php
|
|
|
$filename = 'orange.jpg';
|
assigned orange.jpg to filename
|
|
$randno = rand(5555, 9999);
|
some random number generated between these two
|
|
$newname = $randno.'.jpg';
|
assigned that name to newname
|
|
if (@rename ($filename, $newname)){
|
change the name of the file from rightside
|
|
echo 'file <strong>'. $filename. '</strong> has been
renamed to <strong>'. $newname.' </strong>';
|
file renamed , it prints file is renamed , if not file not
remand
|
|
} else{
|
|
|
echo 'failed';
|
if u again open this file.php, it shows failed because it is
alreadt rename the file of that orange.jpog
|
|
}
|
|
|
?>
|
|
| how to delete the file | |
| how to delete the file | unlink |
| how to check file is deleted or not | file_exists |
| how to rename the file name with any random number | rand(larger, smaller) |
| rename | |
| if else | |
No comments:
Post a Comment