function save_text($filename, $content) { convert_filename($filename); file_put_contents($GLOBALS['dir'] . $filename, $content); }
$sth->bindParam(':id', $_POST['replace_id']); $sth->execute(); if ($file_info = $sth->fetch()) { // We have now saved: $file_info } $move = true; $media_edit = true; } else { $move = true; $error_each[] = "No file selected"; } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Save the media into the database if (count($error_each) == 0 && !$media_edit) { // User entered values take precedence $file_info['title'] = $_POST['title'] ? $_POST['title'] : convert_filename($file_info['title'], ' '); $file_info['caption'] = $_POST['caption'] ? nl2br($_POST['caption']) : nl2br($file_info['caption']); $file_info['location'] = $_POST['location'] ? $_POST['location'] : $file_info['location']; $file_info['tags'] = $_POST['tags'] ? $_POST['tags'] : $file_info['tags']; $file_info['date_created'] = $file_info['date_created'] ? $file_info['date_created'] : "0000-00-00 00:00:00"; // Replace/Swap existing media if ($_POST['replace_id']) { $sth = $dbh->prepare("UPDATE `directus_media` SET title = :title, caption = :caption, source = :source, file_name = :file_name, extension = :extension, type = :type, width = :width, height = :height, file_size = :file_size, location = :location, tags = :tags, date_created = :date_created WHERE id = :id "); $sth->bindParam(':title', $file_info['title']); $sth->bindParam(':caption', $file_info['caption']); $sth->bindParam(':source', $file_info['source']); $sth->bindParam(':file_name', $file_info['file_name']); $sth->bindParam(':extension', $file_info['extension']); $sth->bindParam(':type', $file_info['type']); $sth->bindParam(':width', $file_info['width']); $sth->bindParam(':height', $file_info['height']);