Jump to content

[SOLVED] delete an image


jakebur01

Recommended Posts

to delete an image, could i do something like this?

 

echo"<a href=\"view_images.php?delete=urlencode($file)\">delete image</a>

 

then

if (isset($_GET['delete']))

{

 

$delete_image=c:/images/urldecode($_GET['delete']);

 

unlink("delete_image");

 

}

 

Link to comment
Share on other sites

Yes you can, however your syntax has more bugs than the amazon basin. Here:

<?php
echo "<a href=\"view_images.php?delete=".urlencode($file)."\">delete image</a>";

if(strlen($_GET['delete'])) {
	$delete_image = "c:/images/".urldecode($_GET['delete']);
	unlink($delete_image);
}
?>

Link to comment
Share on other sites

Does ini_set ("display_errors", "1");

error_reporting(E_ALL); log errors when someone is trying to inject stuff into url?

 

How will you know when they are trying to do that? Isn't that what that is for? I read a little bit on ini_set ("display_errors", "1");

error_reporting(E_ALL); but I was having trouble understanding exactly how it works.

 

- Jake

Link to comment
Share on other sites

Ha Ha.... my head way starting to get foggy and his footer looked as though it were part of the post.

 

Sorry....

 

Thank you for all your help. It is working great now.

 

Hehe, yeah I leave it there cause I reference it a lot. 

 

Did you get errors when you added that in your code?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.