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
https://forums.phpfreaks.com/topic/45213-help/
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
https://forums.phpfreaks.com/topic/45213-help/#findComment-220008
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
https://forums.phpfreaks.com/topic/45213-help/#findComment-220136
Share on other sites

Archived

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

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