Remove files from an upload area

6 posts by 2 authors in: Forums > CMS Builder
Last Post: July 25   (RSS)

Is it possible to remove ALL upload files from a multi list with one click of a button, I have a multi list that gets republished each week but we want to remove all files before they get republished because they get changed each week.

Hi MercerDesign, 

Yes, it absolutely is, but be sure to back up and exercise caution when testing any code that has the potential to destroy data.

The line should do it: 

// Remove ALL uploads from ALL records that match this criteria
removeUploads("tableName = 'yourTableName'");

Hope that helps!  

Dave Edis - Senior Developer
interactivetools.com

That's brilliant, thank you

Hi MercerDesign, 

It's due to a change in MySQL 8.0 server.  In /lib/errorlog_functions.php can you try replacing this: 
$query = "DELETE FROM `$table` WHERE `num` < (SELECT `num` FROM `$table` ORDER BY `num` DESC LIMIT 1 OFFSET 999)";
With this: 
$query = "DELETE FROM `$table` WHERE num < (SELECT num FROM (SELECT num FROM `$table` ORDER BY num DESC LIMIT 999, 1) AS sub)";
Let me know if that works for you.

Thanks!
Dave Edis - Senior Developer
interactivetools.com

Thank you, that seems to have worked.