Jump to content

Unlink() Working With Links


lordphate

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
Link to comment
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.
Link to comment
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.
Link to comment
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...
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.