Skip to content

Instantly share code, notes, and snippets.

@0test
Created March 13, 2023 19:14
Show Gist options
  • Save 0test/f498be433fad4fb3e1284ac21f53fd76 to your computer and use it in GitHub Desktop.
Save 0test/f498be433fad4fb3e1284ac21f53fd76 to your computer and use it in GitHub Desktop.
if ($uid && $files && isset($files['photo_file']) && $files['photo_file']['error'] === 0) {
$dir = 'assets/images/' . $uid . '/';
$filename = $FormLister->fs->takeFileName($files['photo_file']['name']);
$ext = $FormLister->fs->takeFileExt($files['photo_file']['name']);
$filename = $modx->stripAlias($filename).'.'.$ext;
$filename = $FormLister->fs->getInexistantFilename($dir.$filename,true);
if ($FormLister->fs->makeDir($dir) && move_uploaded_file($files['photo_file']['tmp_name'],$filename)) {
$data['photo'] = $FormLister->fs->relativePath($filename);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment