Reply to Re: Advice on deleting images from server using PHP

Your name:

Reply:


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.

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация