Home >Backend Development >PHP Tutorial >php unlink delete related issues_PHP tutorial

php unlink delete related issues_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:27:301257browse

php unlink deletion problem

When deleting pictures

For example: unlink('abcdef.jpg');

This way you can delete it normally;

But the file name cannot be deleted when it is read from the database

fn=$rs['abc'];

unlink($fn);

It cannot be deleted. Have any experts encountered such a situation?

Prompt message:

Warning: unlink(user_logo/d4d84f383714d5f3.jpg) [function.unlink]: No such file or directory in

 ------Solution--------------------

Didn’t he make it very clear?

 No such file or directory No such file or directory

 ------Solution--------------------

Error message file does not exist

It should be that the path is wrong

 ------Solution--------------------

First check whether the file exists and then delete it

The warnings are that the file or directory does not exist

 if(file_exists($fn)){

unlink($fn);

 }

 ------Solution--------------------

Look at your user_logo/ directory to see if this file exists in this directory

If not, then delete it. If yes, delete it. Add a judgment

 if(file_exists($fn)){//The file exists

//todo delete

 }

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/820407.htmlTechArticlephp unlink deletion problem when deleting pictures, for example: unlink('abcdef.jpg'); This can be deleted normally; But when the file name is read from the database, it cannot be deleted fn=$rs['abc']; unlink($fn); just...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn