PHP Unlink Removal issues

Source: Internet
Author: User
When you delete a picture
For example: Unlink (' abcdef.jpg ');
This can be removed normally;
However, the file name cannot be deleted when it is read from the database
fn= $rs [' abc '];
Unlink ($FN);
Can not be deleted, the master has encountered such a situation.
Tip Information:
Warning:unlink (user_logo/?d4d84f383714d5f3.jpg) [Function.unlink]: No such file or directory in


Reply to discussion (solution)

Didn't he say it clearly?
No such file or directory does not have such files or directories

Error message file does not exist
It should be the wrong path.

First determine if the file exists and then delete it.
The warning indicates that the file or directory does not exist.

if (file_exists ($FN)) {  unlink ($FN);}

Look at your user_logo/directory to see if this file exists in this directory.
No, no, no, delete, add a judgment.

if (file_exists ($FN)) {//existence of the file//todo delete}

Perhaps the landlord read the data is only the filename, no file suffix it. Check to see if it exists before deleting it.

Fellow unlink (user_logo/?d4d84f383714d5f3.jpg)
The hint is this, so the folder is the name of the file.
This deleted file is the same directory as the picture folder a.php User_logo
Plus I tried not to, but the files and folders are there.

To confirm this, please
Ptint_r (Glob (' user_logo/* '));
Post the results

Call to undefined function ptint_r () error

Call to undefined function ptint_r () error


Print_r

I read it with something else.
0=>326601fbd562175b.jpg
1=>33020b4dfad41335.gif
2=>4d2514d09a181e1b.jpg
3=>c3f7050e4de83d13.gif
4=>d436ccf10d8c8141.gif
5=>d4d84f383714d5f3.jpg
?>

The file is definitely there
0=>./user_logo/326601fbd562175b.jpg
1=>./user_logo/33020b4dfad41335.gif
2=>./user_logo/4d2514d09a181e1b.jpg
3=>./user_logo/c3f7050e4de83d13.gif
4=>./user_logo/d436ccf10d8c8141.gif
5=>./user_logo/d4d84f383714d5f3.jpg

The machine is not going to cheat you, he said no, that's no
Var_dump ($fn = = ' user_logo/?d4d84f383714d5f3.jpg ');
Post the results

BOOL (FALSE)
It's fake, no, but it does.
Unlink (User_logo?1d8daa1bc872d00f.gif)

Yes, users can upload a picture, if modified re-upload the old deleted, the old file name in the database
$dlogo = "Select User_info_logo from Site_user_info where user_info_id=". $_session["userid"];
$drow =mysql_query ($dlogo);
$rs =mysql_fetch_array ($drow);
$LOGOMC = $rs [' User_info_logo '];
if ($LOGOMC) {
$base _dir= "User_logo". $logomc;
Unlink ($base _dir);

$base _dir= "User_logo". $logomc;
Unlink ($base _dir);

$base _dir= "User_logo/". $LOGOMC;
It's not generally possible to store file names/filename
Besides, the files are still in subdirectories.

The following is the file name, preceded by a folder. Just missing/But all the same results
Warning:unlink (user_logo/?d4d84f383714d5f3.jpg) [Function.unlink]: No such file or directory in
Directory files are available, the program does not think

In unlink php Add this sentence, see what output.
echo dirname (__file__). ' User_logo/?d4d84f383714d5f3.jpg ';

Too lazy to look at the top.

Too lazy to look at the top.
In the original posts:
Unlink (' abcdef.jpg '); OK
fn= $rs [' abc ']; Unlink ($FN); No way
You'll have to compare this FN output with ' abcdef.jpg '.
The front of the string operation into the back of the line.

Don't think that using variables will have an effect.
As long as the content can be ...

With absolute path, you are prompted that the path is wrong without the file and folder. See the relative location of PHP files and pictures

Since you use file_exists to judge already exist, also hint you file does not exist then check you do not delete permission. Sometimes it's the authority thing.

?? Oh, my God, I met????,, too. The file exists, but the file is the other?? What's the matter? Besides the hint??
Just like windows, is there a case in use? What if you want to? The file must be prompt??.

?? I found it, but the solution? Method??? Have, hope high finger?

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.