DeleteBatchFile.php
785 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
namespace NinjaForms\Includes\Admin\Processes;
/**
* Deletes a file given file path
*
*
*/
class DeleteBatchFile
{
/**
* Delete a file, given a filepath
*
* @param string $filePath
* @return string Result of the attempt to delete file
*/
public function delete(string $filePath): string
{
$return = __('File could not be found for deletion', 'ninja-forms');
if (\file_exists($filePath)) {
\unlink($filePath);
$return = __('File was deleted', 'ninja-forms');
if (\file_exists($filePath)) {
// couldn't delete file for some reason
$return = __('File could not be deleted', 'ninja-forms');
}
}
return $return;
}
}