All of a sudden my formit2file snippet is causing a parse error
Parse error: syntax error, unexpected '<' in /home/nacgbol1/public_html/emeraldfoundation.ca/core/cache/elements/modsnippet/30.include.cache.php on line 7
When I look at that file this is what you see
<?php
function elements_modsnippet_30($scriptProperties= array()) {
global $modx;
if (is_array($scriptProperties)) {
extract($scriptProperties, EXTR_SKIP);
}
<?php
$output = true;
$path;
$extensions;
So it is easy to see the error, but I do not know how to fix it. Here is my formit2file code:
<?php
$output = true;
$path;
$extensions;
$ext_array = explode(',', $extensions);
$uploadpath = $path;
$target_path = $modx->config['base_path'] . $uploadpath;
$submittedfiles = array_keys($_FILES);
foreach ($submittedfiles as $sf) {
$filename = basename( $_FILES[$sf]['name'] );
$ext = pathinfo($filename, PATHINFO_EXTENSION);
$ext = mb_strtolower($ext); // case insensitive
if($filename != '') {
if(in_array($ext, $ext_array)) {
$filename = mb_strtolower($filename);
$filename = str_replace(' ', '_', $filename);
$filename = date("Ymd_Gis_") . $filename;
$myTarget = $target_path . $filename;
mkdir($target_path, 0755, true);
if(move_uploaded_file($_FILES[$sf]['tmp_name'], $myTarget)) {
$modx->setPlaceholder('fi.'.$sf.'_new', $myTarget);
if (!chmod($myTarget, 0644)) { /*some debug function*/ }
$hook->setValue($sf, $filename);
} else {
$errorMsg = 'There was a problem uploading the file.';
$hook->addError($sf, $errorMsg);
$output = false;
}
} else {
$errorMsg = 'Type of file not allowed.';
$hook->addError($sf, $errorMsg);
$output = false;
}
} else {
$hook->setValue($sf, '');
}
}
return $output;
[ed. note: landonpoburan last edited this post 12 years, 2 months ago.]