Jump to content


Photo

Unlink() Working With Links


  • Please log in to reply
3 replies to this topic

#1 lordphate

lordphate
  • Members
  • PipPipPip
  • Advanced Member
  • 154 posts

Posted 28 June 2006 - 11:45 PM

is there a way to make a file removed by clicking a link?/ here is my 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()');} }  } }?>

any help would be helpful thanks

#2 Eugene

Eugene
  • Members
  • PipPipPip
  • Advanced Member
  • 126 posts

Posted 29 June 2006 - 02:21 AM

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.

#3 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 29 June 2006 - 03:03 AM

[!--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) View Post[/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.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#4 lordphate

lordphate
  • Members
  • PipPipPip
  • Advanced Member
  • 154 posts

Posted 29 June 2006 - 12:30 PM

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users