コード例 #1
0
    foreach ($_FILES as $arrfile) {
        if ($arrfile['name']) {
            $filename = iconv("UTF-8", $target_encoding, basename($arrfile['name']));
            $filename = str_replace('\\', '', $filename);
            $filename = str_replace('/', '', $filename);
            // delete  file if it exists
            while (file_exists($dest . $filename)) {
                unlink($dest . $filename);
                $filename = "new_" . $filename;
            }
            // save the file
            if (!move_uploaded_file($arrfile['tmp_name'], $dest . $filename)) {
                $message = "Upload {$filename} failed.<br/>";
            } else {
                $ext = substr(strrchr($filename, '.'), 1);
                StaticAsset::createStaticAsset($save, $filename, $ext);
                $location = ViewUrl::getViewUrl($save);
                if ($location) {
                    header("location: view.php?location=" . $location);
                } else {
                    header("location: view.php");
                }
            }
        }
    }
}
//get default value for the textarea (either from selecting an item in the history, or from the current active record)
$name = empty($save) ? $_GET['name'] : $save;
if ($_GET['init']) {
    $row = StaticAsset::getStaticAssetById($_GET['init']);
} else {