Click here to Skip to main content
15,910,787 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am developing a site. I upload image files to a directory "images". using SQL query I generate a list of my required images and each image has a REMOVE link in front of it.
I have not given any href value to any REMOVE link yet. I want to use a secure way to delete the file (So that none of my directory info appears anywhere). What Should I do that When I click on the REMOVE link, the File should be removed.
Posted

You should call the unlink(string filename)[^] function...

Really easy to use... check it and come back if you have some issues...

HTH! :thumbsup:

PS: anyway a simple "delete files PHP" search in google would have given the same result...
 
Share this answer
 
Comments
rashidfarooq 12-May-11 9:14am    
I know how to delete a file using unlink or delete function. But I think you have not understand my issue. My Issue is not how to delete a file. My issue is if I gave the file path as the href value of REMOVE link and pass it using GET to the unlink function, then my file path info will be displayed. But I have noticed in Some Big sites (like yahoo) When We upload any file, a REMOVE link appears against the file after being uploaded. When We Click REMOVE Link, file got deleted and no info appears any where. I want to use such like a way.
Joan M 12-May-11 9:16am    
OK... my fault... :$ sorry for misunderstanding you...
Have a parameter action that specifies the action and also a parameter that identifies the image in the database (an ID column for instance). When the page is called with an action that corresponds to a delete take the parameter ID and fetch the path where it is in your directory structure from the database. Now you can delete it and nobody has seen anything for your directory structure.

Hope that helps you get started.

-MRB
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900