Click here to Skip to main content
15,500,220 members
Home / Discussions / Linux, Apache, MySQL, PHP
   

Linux, Apache, MySQL, PHP

 
GeneralRe: send data Pin
effayqueue25-Mar-11 2:25
Membereffayqueue25-Mar-11 2:25 
GeneralRe: send data Pin
cjoki25-Mar-11 3:52
Membercjoki25-Mar-11 3:52 
GeneralRe: send data Pin
Elham M25-Mar-11 4:15
MemberElham M25-Mar-11 4:15 
GeneralRe: send data Pin
cjoki25-Mar-11 4:32
Membercjoki25-Mar-11 4:32 
GeneralRe: send data Pin
Elham M25-Mar-11 8:05
MemberElham M25-Mar-11 8:05 
GeneralRe: send data Pin
cjoki25-Mar-11 11:02
Membercjoki25-Mar-11 11:02 
GeneralRe: send data Pin
Elham M25-Mar-11 22:17
MemberElham M25-Mar-11 22:17 
GeneralRemove a File Using PHP Pin
Haroon Mughal23-Mar-11 3:35
MemberHaroon Mughal23-Mar-11 3:35 
To remove a file from php use the unlink() function. You can enter either the full path or the relative path to the file. You can see the examples below. All of them are valid.

unlink('deleteme.txt');
unlink('/home/arman/public_html/deleteme.txt');
unlink('./deleteme.txt');
unlink('../deleteme.txt');

PHP will give you a warning if the file you want to remove doesn't exist so you may want to force php to be quiet using the '@' character like this :

@unlink('./deleteme.txt');
Or you can first test if the file exist or not like thigs

$fileToRemove = '/home/arman/public_html/deleteme.txt';
if (file_exists($fileToRemove))) {
// yes the file does exist
unlink($fileToRemove);
} else {
// the file is not found, do something about it???
}

PHP will also give you a warning if you don't have enough permission to delete the file. It would be better if your code check if the file is removed successfully or not like show below

$fileToRemove = '/home/arman/public_html/deleteme.txt';
if (file_exists($fileToRemove)) {
// yes the file does exist

if (@unlink($fileToRemove) === true) {
// the file successfully removed
} else {
// something is wrong, we may not have enough permission
// to delete this file
}
} else {
// the file is not found, do something about it???
}
GeneralRe: Remove a File Using PHP Pin
Joan M30-Mar-11 8:48
professionalJoan M30-Mar-11 8:48 
GeneralPHP Tips By Google Master Pin
Haroon Mughal23-Mar-11 3:33
MemberHaroon Mughal23-Mar-11 3:33 
GeneralPHP performance tips Pin
Haroon Mughal23-Mar-11 3:32
MemberHaroon Mughal23-Mar-11 3:32 
Questioncss and link styles Pin
Joan M22-Mar-11 5:59
professionalJoan M22-Mar-11 5:59 
AnswerRe: css and link styles Pin
Luc Pattyn22-Mar-11 6:25
sitebuilderLuc Pattyn22-Mar-11 6:25 
QuestionWhy do images are not shown? Pin
Joan M21-Mar-11 6:43
professionalJoan M21-Mar-11 6:43 
AnswerRe: Why do images are not shown? Pin
Luc Pattyn21-Mar-11 6:50
sitebuilderLuc Pattyn21-Mar-11 6:50 
GeneralRe: Why do images are not shown? Pin
Joan M21-Mar-11 7:10
professionalJoan M21-Mar-11 7:10 
GeneralRe: Why do images are not shown? Pin
Luc Pattyn21-Mar-11 7:22
sitebuilderLuc Pattyn21-Mar-11 7:22 
GeneralRe: Why do images are not shown? Pin
Joan M21-Mar-11 7:22
professionalJoan M21-Mar-11 7:22 
AnswerRe: Why do images are not shown? Pin
Luc Pattyn21-Mar-11 7:24
sitebuilderLuc Pattyn21-Mar-11 7:24 
GeneralRe: Why do images are not shown? Pin
Joan M21-Mar-11 7:47
professionalJoan M21-Mar-11 7:47 
GeneralRe: Why do images are not shown? Pin
Luc Pattyn21-Mar-11 7:52
sitebuilderLuc Pattyn21-Mar-11 7:52 
GeneralRe: Why do images are not shown? Pin
Joan M21-Mar-11 8:09
professionalJoan M21-Mar-11 8:09 
GeneralRe: Why do images are not shown? Pin
Luc Pattyn21-Mar-11 8:17
sitebuilderLuc Pattyn21-Mar-11 8:17 
QuestionRe: Why do images are not shown? Pin
Joan M21-Mar-11 8:30
professionalJoan M21-Mar-11 8:30 
AnswerRe: Why do images are not shown? Pin
Luc Pattyn21-Mar-11 8:43
sitebuilderLuc Pattyn21-Mar-11 8:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.