steviez Posted April 2, 2007 Share Posted April 2, 2007 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 More sharing options...
emehrkay Posted April 2, 2007 Share Posted April 2, 2007 just an idea - store a reference to the file in a table. in that table store a unique-random val and use it as a part of the url. delete.php?id=asdlaksjdfasodfjals2323 then just run a check against that id Link to comment https://forums.phpfreaks.com/topic/45213-help/#findComment-219543 Share on other sites More sharing options...
jitesh Posted April 2, 2007 Share Posted April 2, 2007 yes its easy. generate a file delete.php file and use unlink(); Link to comment https://forums.phpfreaks.com/topic/45213-help/#findComment-219588 Share on other sites More sharing options...
steviez Posted April 2, 2007 Author Share Posted April 2, 2007 im new to php, anyone help at all? Link to comment https://forums.phpfreaks.com/topic/45213-help/#findComment-220000 Share on other sites More sharing options...
emehrkay Posted April 2, 2007 Share Posted April 2, 2007 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 More sharing options...
MadTechie Posted April 2, 2007 Share Posted April 2, 2007 Maybe the freelance section or book review might help, as we can help you but we're not going to write the whole thing for you. Link to comment https://forums.phpfreaks.com/topic/45213-help/#findComment-220010 Share on other sites More sharing options...
steviez Posted April 2, 2007 Author Share Posted April 2, 2007 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 More sharing options...
emehrkay Posted April 2, 2007 Share Posted April 2, 2007 is $file a random code or a path to the file? if(file_exists($file)){ unlink($rsFile); } Link to comment https://forums.phpfreaks.com/topic/45213-help/#findComment-220182 Share on other sites More sharing options...
steviez Posted April 2, 2007 Author Share Posted April 2, 2007 random code Link to comment https://forums.phpfreaks.com/topic/45213-help/#findComment-220183 Share on other sites More sharing options...
emehrkay Posted April 2, 2007 Share Posted April 2, 2007 i would assume that $rsFile is the path to the file? if so, you need to check to see if that exists, not your random code Link to comment https://forums.phpfreaks.com/topic/45213-help/#findComment-220185 Share on other sites More sharing options...
steviez Posted April 2, 2007 Author Share Posted April 2, 2007 i did not write the script, im thinking that the $rsFile is part of the mysql code as it is in all of the script Link to comment https://forums.phpfreaks.com/topic/45213-help/#findComment-220188 Share on other sites More sharing options...
steviez Posted April 3, 2007 Author Share Posted April 3, 2007 Any ideas guys? Link to comment https://forums.phpfreaks.com/topic/45213-help/#findComment-220686 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.