protected function elFinderVolumeDrupal::_save in elFinder file manager 7.2
Same name and namespace in other branches
- 8.2 src/Controller/elFinderVolumeDrupal.php \elFinderVolumeDrupal::_save()
- 6.2 inc/elfinder.drupalfs.driver.inc \elFinderVolumeDrupal::_save()
- 7.3 inc/elfinder.drupalfs.driver.inc \elFinderVolumeDrupal::_save()
Create new file and write into it from file pointer. Return new file path or false on error.
@author Dmitry (dio) Levashov, Alexey Sukhotin
Parameters
resource $fp file pointer:
string $dir target dir path:
string $name file name:
Return value
bool|string
File
- inc/
elfinder.drupalfs.driver.inc, line 263 - elFinder driver for Drupal filesystem.
Class
- elFinderVolumeDrupal
- @file
Code
protected function _save($fp, $dir, $name, $stat) {
$tmpname = $name;
$bu_ret = module_invoke_all('elfinder_beforeupload', array(
'name' => $name,
'dir' => $dir,
'stat' => $stat,
));
if (isset($bu_ret)) {
if (!is_array($bu_ret)) {
$bu_ret = array(
$bu_ret,
);
}
$tmpname = end($bu_ret);
}
$path = $dir . DIRECTORY_SEPARATOR . (!empty($tmpname) ? $tmpname : $name);
if (!$this
->CheckUserQuota()) {
return FALSE;
}
if (!$this
->CheckFolderCount($dir)) {
return FALSE;
}
if (!$this
->CheckExtension($this
->_drupalfileobject($path))) {
return FALSE;
}
if (!$this
->FileValidate($name)) {
return FALSE;
}
if (!($target = @fopen($path, 'wb'))) {
return FALSE;
}
while (!feof($fp)) {
fwrite($target, fread($fp, 8192));
}
fclose($target);
@chmod($path, $this->options['fileMode']);
$file = $this
->_drupalfileobject($path);
@file_save($file);
$this
->FileUsageAdd($file);
return $path;
}