forked from terminal42/contao-notification_center
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for form uploads that can now be attached to e.g. e-mai…
…ls (terminal42#39)
- Loading branch information
Showing
2 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
/** | ||
* notification_center extension for Contao Open Source CMS | ||
* | ||
* @copyright Copyright (c) 2008-2015, terminal42 | ||
* @author terminal42 gmbh <[email protected]> | ||
* @license LGPL | ||
*/ | ||
|
||
|
||
namespace NotificationCenter\Util; | ||
|
||
|
||
class Form | ||
{ | ||
/** | ||
* Moves an uploaded file to the tmp folder and returns its TL_ROOT relative path. | ||
* If it was not properly uploaded, the method will return null. | ||
* | ||
* @param array $file | ||
* @return null|string | ||
*/ | ||
public static function getFileUploadPathForToken(array $file) | ||
{ | ||
if (!is_uploaded_file($file['tmp_name'])) { | ||
|
||
return null; | ||
} | ||
|
||
$tmpDir = 'system/tmp'; | ||
$filePath = $tmpDir . '/' . $file['name']; | ||
|
||
\Files::getInstance()->move_uploaded_file($file['tmp_name'], $filePath); | ||
\Files::getInstance()->chmod($filePath, $GLOBALS['TL_CONFIG']['defaultFileChmod']); | ||
|
||
|
||
return $filePath; | ||
} | ||
} |