Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Asset exists check for files within folders when drag and dropping. #725

Open
wants to merge 4 commits into
base: 1.6
Choose a base branch
from
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
3 changes: 2 additions & 1 deletion public/js/pimcore/asset/tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,8 @@
url: Routing.generate('pimcore_admin_asset_exists'),
params: {
parentId: parentNode.id,
filename: file.name
filename: file.name,
dir: path
},
async: false,
success: function (response) {
Expand Down
14 changes: 13 additions & 1 deletion src/Controller/Admin/Asset/AssetController.php
Original file line number Diff line number Diff line change
Expand Up @@ -401,8 +401,20 @@ public function existsAction(Request $request): JsonResponse
{
$parentAsset = \Pimcore\Model\Asset::getById((int)$request->get('parentId'));

$dir = $request->get('dir', '');
if ($dir){
// this is for uploading folders with Drag&Drop
// param "dir" contains the relative path of the file
if (strpos($dir, '..') !== false) {
throw new \Exception('not allowed');
}
$dir = '/' . trim($dir, '/ ');
}

$assetPath = $parentAsset->getRealFullPath() . $dir . '/' . $request->get('filename');

return new JsonResponse([
'exists' => Asset\Service::pathExists($parentAsset->getRealFullPath().'/'.$request->get('filename')),
'exists' => Asset\Service::pathExists($assetPath),
]);
}

Expand Down
Loading