Jump to content

Recommended Posts

Hi, I have some question to ask about this code. I have a images path store into config.ini. I can display the images only the problem is I want to click and delete the image after confirm.

 

Please help...

 

index.php

$file = $_SERVER['DOCUMENT_ROOT'] . "/uploads/config.ini";
$contents = file($file);
$string = implode($contents);

$lines = file($file);

print "<table border=1><tr>";

foreach ($lines as $line_num => $line) {

echo "
<td WIDTH=220 HEIGHT=220>
<a title=\"Delete File\" href=\"javascript:;\" onClick=\"cf=confirm('Are you sure you want to delete?');if (cf)window.location='functions.php?action=del&file=" . htmlspecialchars($line) . "'; return false;\">
<IMG SRC=" . htmlspecialchars($line) . " WIDTH=\" \" HEIGHT=\" \" BORDER=\"0\"  TITLE=\" " . htmlspecialchars($line) . " \" \/>
</a><br />
</td>";
}

print "</tr></table>";

 

functions.php

$action = $_GET['action'];

switch($action) {	

case 'del':
unlink($_GET['file']);


break ;
}

Link to comment
https://forums.phpfreaks.com/topic/174194-click-and-delete/
Share on other sites

There are other possibilities but, AJAX is actually the easiest option. That is if you still don't want the user to be redirected to another page?

 

actually i just need someone to help on my code, is that a problem? i trying to click and delete the images but it seem doesn't show the prompt message. maybe without ajax or someone can help?

Link to comment
https://forums.phpfreaks.com/topic/174194-click-and-delete/#findComment-918805
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.