I'm having some issues deleting some images that i have on a folder on my server using php. I've come up with the following code, but i keep getting this error when i test it:
Warning: unlink(images/gallery/slideshow/) [function.unlink]: Is a directory in /home2/socalcom/public_html/yourimageisart/deleteImage.php on line 11
The file images/gallery/slideshow/ could not be deleted.
First here is the code from the form
<form method="post" action="deleteImage.php"><ul>
<li>
<input type="image" name="imagefile" src="images/gallery/slideshow/Winter.jpg" height="75" width="75" /><br/>
<input type="submit" name="submit" value="Delete"/>
</li>
<li>
<input type="image" name="imagefile" src="images/gallery/slideshow/yinyang11024.jpg" height="75" width="75" /><br/>
<input type="submit" name="submit" value="Delete"/>
</li>
<li>
<input type="image" name="imagefile" src="images/gallery/slideshow/Sunset.jpg" height="75" width="75" /><br/>
<input type="submit" name="submit" value="Delete"/>
</li>
</ul>
</form>
Finally here is the code for deleteImage.php
<?php
$path="images/gallery/slideshow/"; //path of images
$image = $_POST['imagefile'];
$file = $path . $image;
if(file_exists($file))
{
if(unlink($file))
{
echo "The file <i>".$file."</i> has been deleted.";
}
else
{
echo "The file <i>".$file."</i> could not be deleted.";
}
}
else
{
echo "The file <i>".$file."</i> could not be found.";
}
?>
Any help ?
Warning: unlink(images/gallery/slideshow/) [function.unlink]: Is a directory in /home2/socalcom/public_html/yourimageisart/deleteImage.php on line 11
The file images/gallery/slideshow/ could not be deleted.
First here is the code from the form
<form method="post" action="deleteImage.php"><ul>
<li>
<input type="image" name="imagefile" src="images/gallery/slideshow/Winter.jpg" height="75" width="75" /><br/>
<input type="submit" name="submit" value="Delete"/>
</li>
<li>
<input type="image" name="imagefile" src="images/gallery/slideshow/yinyang11024.jpg" height="75" width="75" /><br/>
<input type="submit" name="submit" value="Delete"/>
</li>
<li>
<input type="image" name="imagefile" src="images/gallery/slideshow/Sunset.jpg" height="75" width="75" /><br/>
<input type="submit" name="submit" value="Delete"/>
</li>
</ul>
</form>
Finally here is the code for deleteImage.php
<?php
$path="images/gallery/slideshow/"; //path of images
$image = $_POST['imagefile'];
$file = $path . $image;
if(file_exists($file))
{
if(unlink($file))
{
echo "The file <i>".$file."</i> has been deleted.";
}
else
{
echo "The file <i>".$file."</i> could not be deleted.";
}
}
else
{
echo "The file <i>".$file."</i> could not be found.";
}
?>
Any help ?