Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ Let's assume there is an edit.html.twig template associated with the edit action
$(function() {
new PunkAveFileUploader({
'uploadUrl': {{ path('upload', { editId: editId }) | json_encode | raw }},
'viewUrl': {{ '/uploads/tmp/attachments/' ~ editId | json_encode | raw }},
'viewUrl': {{ '/uploads/tmp/attachments/#{editId}' | json_encode | raw }},
'el': '.file-uploader',
'existingFiles': {{ existingFiles | json_encode | raw }},
'delaySubmitWhileUploading': '.edit-form'
Expand Down
37 changes: 33 additions & 4 deletions Services/FileManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,16 @@ public function removeFiles($options = array())
{
throw \Exception("folder option looks empty, bailing out");
}
system("rm -rf " . escapeshellarg($folder));
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN')
{
//Running on Windows
system('rd /s/q ' . escapeshellarg($folder));
}
else
{
//Not running on Windows. Hoping it's a Linux
system("rm -rf " . escapeshellarg($folder));
}
}

/**
Expand Down Expand Up @@ -106,14 +115,34 @@ public function syncFiles($options = array())
{
throw new \Exception("to_folder does not exist");
}
system("rsync -a --delete " . escapeshellarg($from . '/') . " " . escapeshellarg($to), $result);
if ($result !== 0)
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN')
{
//Running on Windows
system("robocopy /Mir /NP /NDL /NFL /NJH /NJS " . escapeshellarg($from . '/') . " " . escapeshellarg($to), $result);
$kk=1;
}
else
{
//Not running on Windows. Hoping it's a Linux
system("rsync -a --delete " . escapeshellarg($from . '/') . " " . escapeshellarg($to), $result);
$kk=0;
}
if ($result !== $kk)
{
throw new \Exception("Sync failed");
}
if (isset($options['remove_from_folder']) && $options['remove_from_folder'])
{
system("rm -rf " . escapeshellarg($from));
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN')
{
//Running on Windows
system('rd /s/q ' . escapeshellarg($from));
}
else
{
//Not running on Windows. Hoping it's a Linux
system("rm -rf " . escapeshellarg($from));
}
}
}
else
Expand Down