I have a script where when I press delete it deletes information in the database according to the ID passed, but there is a file name in the database as well that is shows where the file was uploaded, how would I pass the filename from the database into codeigniter to see if the file exists and if it does, delete it.
Also there will be multiple rows on occasions with different file names where I would need it to delete all the file it returns.
I am a beginner so you will need to explain things more than usual, I don’t even know where to begin for this, I searched around Google and here for about an hour or so with no luck.
Without knowing your database schema, the only suggestion I have for pulling it out is to use the
get_wherehelper in the database library to retrieve the record in question. Once you have it, you can check and delete it usingfile_existsandunlink. I’ll assume the filepaths you wish to delete are in an array called$resultsAs a general matter of course, it’s very helpful to see relevant pieces of your code before trying to answer your question. I hope the example above is enough to get you started!