XeroXer Posted November 22, 2006 Share Posted November 22, 2006 Hi there!I ma making a simple site for a friend of mines counter-strike clan.Verything is done from his point of view but I think that one thing is missing.I have allowed them to upload images and insert them into members sections.Now I also want to add so that they can delete the images.If they upload one file named member1.gif I haven't added any option to overwrite it the next time so it displays an error.So then they rename the image to member1-1.gif and it goes on and on.So I want to add a delet file section.And I though what better place to fix it than here.The security section is already done so all I need is the delete "sequence" :).The file will be placed in a folder named clan and then in that folder there will be a file called upload with all the images in.I want a PHPscript that reads the content of that foler and lists it in a drop-down menu.There you choose the filke you wish to delete and press delete (submit).The file should then be deleted and a success message should be printed out.If anyone can make this, has it laying around or could give me pointers so I can make it myself I would be very happy....:)Have a nice day all! Quote Link to comment https://forums.phpfreaks.com/topic/28122-simple-delete-file-form/ Share on other sites More sharing options...
XeroXer Posted November 22, 2006 Author Share Posted November 22, 2006 Another question then?What command do I use to delete a file?And how do I list the content of a folder in a drop-down menu? Quote Link to comment https://forums.phpfreaks.com/topic/28122-simple-delete-file-form/#findComment-128742 Share on other sites More sharing options...
emediastudios Posted October 28, 2007 Share Posted October 28, 2007 Did you find an answer?I have the same prblem solved Quote Link to comment https://forums.phpfreaks.com/topic/28122-simple-delete-file-form/#findComment-379749 Share on other sites More sharing options...
GingerRobot Posted October 28, 2007 Share Posted October 28, 2007 A very simple way of doing it:[code]<?phpif(isset($_POST['submit'])){ unlink($_POST['file']); echo $_POST['file'].' deleted';}?><form action="<?php echo $_SERVER['phpself']; ?>" method="POST" /><?phpecho '<select name="file">';foreach(glob('*.*') as $file){ echo '<option value="'.$file.'">'.$file.'</option>'."\n";}echo '</select>';?><input type="submit" name="submit" value="Delete!"</form>[/code]You might want to secure that a bit though. Quote Link to comment https://forums.phpfreaks.com/topic/28122-simple-delete-file-form/#findComment-379758 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.