Jump to content

Recommended Posts

Hi,

 

I am having a problem with deleting images. It worked a little while ago and cant think what I have done to change it.

 

This lists and displays the images in the specified directory, but when I check the checkbox and click delete, instead of going to the specified delete.php script, it just lists the contents of the public_html directory.

 

uploaded_files.php

 

<?php
session_start();  
if($_SESSION['valid'] == true) 
{
include_once("../common/header.php");
$username = $_GET['username'];
print "<table width=700 border=0 align=center cellpadding=0 cellspacing=0>";
    print "<tr>";
    print "<td valign=top>";
print "<table width=700 border=0 cellpadding=0 cellspacing=0>";
    print "<tr>";
print "<td>";
print "<table width=100% border=0 cellpadding=0 cellspacing=0>";
print "<tr>";
print "<td colspan=2>";
print "<h2 class=style2>Members Area<br /></h2>";
print "<hr />";
print "</td>";
print "</tr>";
print "<tr>";
print "<td class=style3>Your login has been successful</td>";
print "</tr>";
print "<tr>";
print "<td>";
print "</br>";
print "<table border=0>";
print "<tr>";
    print "<td>";
print "<FORM>";
print "<input style='width: 188px;' style='background-color:#6495ED;' type='button' value='Upload Files' onclick=window.location.href='uploadform.php?&username=$username'>"; 
print "</td></tr>";
print "<tr><td>";
print "<input style='width: 188px;' style='background-color:#6495ED;' type='button' value='View Uploaded Files' onclick=window.location.href='uploaded_files.php?&username=$username'>"; 
print "</td></tr>";
print "<tr><td>";
print "<input style='width: 188px;' style='background-color:#6495ED;' type='button' value='Logout' onclick=window.location.href='logout.php?&username=$username'>"; 
    print "</FORM>";
print "</td>";
print "</tr>";
print "</table>";
print "<br />";
print "</td>";
    print "</tr>";
print "</table>";
print "</form>";
print "<br />";
print "<table width=300 border=1 cellpadding=0 cellspacing=0>";
print "<tr>";
print "<td>";
print "<table width=90% border=0 cellpadding=5 cellspacing=0>";
print "<tr>";
print "<td class=style3>Visit another secure page. </td>";
print "</tr>";
print "<tr>";
print "<td>";
print "<h2><a href=loggedin2.php>Go to page 2</a></h2>";
print "</td>";
print "</tr>";
print "</table>";
print "</td>";
print "</tr>";
print "</table>";
    print "</td>";
    print "<td>";
print "</br>";
print "</br>";

$path = "../../../../members/uploads/$username/";
$dir_handle = @opendir($path) or die("Unable to open folder");
while (false !== ($upload = readdir($dir_handle))) {

if($upload == ".")
continue;
if($upload == "..")
continue;

print "<form action=delete.php?&username=$username method=POST>";
print "<table>";
print "<tr><td>";
print "<input type=checkbox name=upload value=../../../../members/uploads/$username/$upload>";
print "<img src='../../../../members/uploads/$username/$upload' alt='../../../../members/uploads/$username/$upload' height=100 width=100><br />";
print "<input type=submit name=delete value=Delete>";
print "</td></tr>";
print "</table>";
print "</form>";
}
closedir($dir_handle);
    print "</td>";
    print "</tr>";
print "</table>";
print "</body>";
print "</html>";
include_once("../common/footer.php");
} else {
header("Location: ../../login.php");

}
?>

 

delete.php

 

<?php
$username = $_GET['username'];
if ($_POST["upload"])
{ 
$myfile = $_POST['upload'];
unlink($myfile);
echo "File Deleted";
} else {
echo "File Delete Unsuccessful";
}

?>

Link to comment
https://forums.phpfreaks.com/topic/156012-solved-unlink-error/
Share on other sites

Hi,

 

Yes the path to the file is correct, as I have the file displayed with img src before selecting it to delete.

 

I cant put the script in the same directory as the uploaded files as the uploaded files are in a folder outside of the cgi-bin where the script is located.

 

I cannot view uploaded files if they are stored within the cgi-bin. :(

Link to comment
https://forums.phpfreaks.com/topic/156012-solved-unlink-error/#findComment-821404
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.