If you have no objections to creating and running a stored procedure
on the database then you can do it entirely without using PHP.
create procedure `speditalltables`()
begin
declare _strsql varchar(512);
declare _table varchar(128);
declare done int default false;
declare res integer default 0;
declare _cursor cursor for select `table_name` as 'name'
from `information_schema`.`tables`
where `table_type`='base table' and `table_schema`=database();
declare continue handler for not found set done=true;
open _cursor;
repeat
fetch _cursor into _table;
if not done then
/* different column names ~ edit as appropriate */
set @strsql=concat("update `",database(),"`.`",_table,"`
set
`filepath`=replace( `filepath`, '/uploads/', '/files1/' ),
`filepath2`=replace( `filepath`, '/uploads/', '/files1/' ),
`filepath3`=replace( `filepath`, '/uploads/', '/files1/' ),
`filepath4`=replace( `filepath`, '/uploads/', '/files1/' )");
prepare stmt from @strsql;
execute stmt;
deallocate prepare stmt;
end if;
until done end repeat;
close _cursor;
select 'finished' as 'result';
set done=null;
set @res=null;
set @_table=null;
end