Posted by Frankie on 07/15/06 16:48
"Krustov" <me@privacy.net> wrote in message
news:MPG.1f21bdb8fd6cf7f9989bea@news.newsreader.com...
>
> I'd start by breaking it down a little .
>
> $temp1="$_POST['hfCategory']";
> print "temp1 = $temp1 <br>";
>
> $temp2="$_POST['hfItemNumber']";
> print "temp2 = $temp2 <br>";
>
> $filename="$temp1/photos/$temp2" . ".jpg";
>
> Making sure you have the path 100% correct is the first step .
>
> TMK "../" doesnt need to be used unless you have good reason to do so .
Thanks again for your help.
I have found the error. Your original code's conditional statement read:
if (!file_exists($filename)) {$pass=1;}
I missed the "!", so it would only delete the file if it did NOT exist. But
it does.
I have since corrected and simplified the code to this:
$pass=0;
$photo="../$hfCategory/photos/$hfItemNumber.jpg";
if (file_exists($photo)) {$pass=1;}
if ($pass==1) {unlink($photo);}
...and it works beautifully.
BTW: in my case, the "../" in the file path IS required in order to locate
the file. The actual sample file path is thus:
"../lifestyle/photos/6000.jpg"
F.H.
Navigation:
[Reply to this message]
|