Jump to content

help


steviez

Recommended Posts

Hi,

 

I am running a file hosting site, when a user uploads a file they are given a download link upon successfull upload. Is it possable to also give them a delete link? If so how??

 

The download link is in this form:

 

<?php echo SITE_URL."/v/".$_SESSION['key']."/".$rsFile->fields['filename'].".html"; ?>

Link to comment
Share on other sites

what i am saying assumes that you store a referece to each file uploaded in a db table.

 

in that table add a field that id's the file, some random 15 char string

 

on your delete link do

 

delete.php?file=randomstringasdfasodf

 

in your delete.php file do

 

$file = $_GET['file'];

 

then check the db for that random unique string

 

'SELECT path FROM files WHERE identifer = '. $file;

 

now you have the path to that file that you stored in that same table

 

unlink(that file path);

Link to comment
Share on other sites

Hi,

 

Thanks for all your help so far, I have managed to get a delet code generated and working, also i can get the code to delet the file from the DB. The only thing i can not do is remove it from the server... here is my file:

 

<?php

include "admin/config.php";

include "conn.php";

include "functions.php";



$file = $_GET['file'];

$strSql = "select * from xl_files WHERE del_key = $file";

$rsFile = $conn->execute($strSql);

if(file_exists($file)){
	unlink($rsFile);
}

$strSql = "delete from xl_files WHERE del_key = $file";

$conn->execute($strSql);

goto("index.php".strstr($_SERVER['HTTP_REFERER'],"?"));

?>

 

any ideas whats wrong?

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.