Added the ability to edit and delete posts which includes uploading of images for the posts and managing those images

Signed-off-by: rodude123 <rodude123@gmail.com>
This commit is contained in:
2023-07-12 03:29:56 +01:00
parent be5e047f51
commit 3b71ba4d23
26 changed files with 1549 additions and 315 deletions
+27
View File
@@ -3,6 +3,8 @@
namespace api\utils;
use Psr\Http\Message\UploadedFileInterface;
use RecursiveDirectoryIterator;
use RecursiveIteratorIterator;
class imgUtils
{
@@ -40,4 +42,29 @@ class imgUtils
return array("imgLocation" => $targetFile);
}
/**
* Deletes a directory and all its contents
* @param string $path - Path to the directory to delete
*/
public function deleteDirectory(string $path): void
{
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path,
RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::CHILD_FIRST);
foreach ($iterator as $file)
{
if ($file->isDir())
{
rmdir($file->getPathname());
}
else
{
unlink($file->getPathname());
}
}
rmdir($path);
}
}