Jump to content

unlink ERROR


phpretard

Recommended Posts

I am delteting a file from a directory and get this error.

 

unlink(test.pdf) [function.unlink]: No such file or directory in...

 

HOWEVER THE FILE IS BEING DELETED???

 

<?
$docName=$_POST['docName'];
$location=$_POST['location'];
$id=$_POST['id'];

$TheFile=$location;
unlink($TheFile);

$delete=mysql_query("DELETE FROM documents WHERE id='$id'");
?>

 

Can anyone explain this?

Link to comment
https://forums.phpfreaks.com/topic/146243-unlink-error/
Share on other sites

<?php
$docName=$_POST['docName'];
$location=$_POST['location'];
$id=$_POST['id'];

$TheFile=$location;
if (file_exists($TheFile)) {
  unlink($TheFile);
} else {
  echo "Sorry, but the file " . htmlentities($TheFile) . " does not exist";
}

$delete=mysql_query("DELETE FROM documents WHERE id='$id'");
?>

Link to comment
https://forums.phpfreaks.com/topic/146243-unlink-error/#findComment-767792
Share on other sites

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.