Jump to content

Archived

This topic is now archived and is closed to further replies.

lordphate

Unlink() Working With Links

Recommended Posts

is there a way to make a file removed by clicking a link?/ here is my code
[code]
<?php

$id = $_GET["id"];
$ip = $_SERVER[REMOTE_ADDR];

include 'header.php';
include 'sidebar.php';
include './library/db.php';
include './library/sessions.php';
if ($member == "arshem") {
    if($id != "")
    {
        $query  = "SELECT id, name, size, path, uploader FROM upload";
$result = mysql_query($query) or die('Error, query failed');
if(mysql_num_rows($result) == 0)
{
    echo "No Files to Delete...Be the first Uploader! <br>";
}
else
{
while(list($fileid, $filename, $size, $filePath, $uploader) = mysql_fetch_array($result))
     {  ?>



<html>
<head>
<title>Delete File</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<div id="main">
   You're Being Watched <?=$ip;?>... <br /><br />
<a href="admin.php?id=<?=$fileid;?>">-<?=$filename;?></a>   <br>
<?php
    include 'footer.php';
?>
</div>
</body>
</html>
<?php
unlink("$filePath");

        mysql_query("DELETE FROM upload WHERE id = '$fileid'") or die('mysql_error()');} }  } }?>[/code]

any help would be helpful thanks

Share this post


Link to post
Share on other sites
FTP access.

You can use it to delete files.

[a href=\"http://us3.php.net/manual/en/ref.ftp.php\" target=\"_blank\"]http://us3.php.net/manual/en/ref.ftp.php[/a]

If you have the files in the database, I think your doing everything right.

Share this post


Link to post
Share on other sites
[!--quoteo(post=389068:date=Jun 29 2006, 02:21 AM:name=G F D)--][div class=\'quotetop\']QUOTE(G F D @ Jun 29 2006, 02:21 AM) [snapback]389068[/snapback][/div][div class=\'quotemain\'][!--quotec--]
FTP access.

You can use it to delete files.

[a href=\"http://us3.php.net/manual/en/ref.ftp.php\" target=\"_blank\"]http://us3.php.net/manual/en/ref.ftp.php[/a]

If you have the files in the database, I think your doing everything right.
[/quote]

Try to use the full path on the unlink to see if it is deleting a file ok.

Share this post


Link to post
Share on other sites
Yes the files are int he database and on my server...so unlink will not work with links...i have to use FTP... the way i HAD it set up was when i went to the script page it would end up deleting EVERYTHING...instead of a certain file...No clicking was needed to delete all the files, it owuld just delete them on it's own...Any ideas besides the FTP function to make Unlink() work with active links...user needs to click on link to delete the database and file server entries...

Share this post


Link to post
Share on other sites

×

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.