/** * Saves an uploaded media file * * @author Andreas Gohr <*****@*****.**> * @author Michael Klier <*****@*****.**> * @author Kate Arzamastseva <*****@*****.**> */ function media_upload_finish($fn_tmp, $fn, $id, $imime, $overwrite, $move = 'move_uploaded_file') { global $conf; global $lang; global $REV; $old = @filemtime($fn); if (!@file_exists(mediaFN($id, $old)) && @file_exists($fn)) { // add old revision to the attic if missing media_saveOldRevision($id); } // prepare directory io_createNamespace($id, 'media'); if ($move($fn_tmp, $fn)) { @clearstatcache(true, $fn); $new = @filemtime($fn); // Set the correct permission here. // Always chmod media because they may be saved with different permissions than expected from the php umask. // (Should normally chmod to $conf['fperm'] only if $conf['fperm'] is set.) chmod($fn, $conf['fmode']); msg($lang['uploadsucc'], 1); media_notify($id, $fn, $imime, $old); // add a log entry to the media changelog if ($REV) { addMediaLogEntry($new, $id, DOKU_CHANGE_TYPE_REVERT, sprintf($lang['restored'], dformat($REV)), $REV); } elseif ($overwrite) { addMediaLogEntry($new, $id, DOKU_CHANGE_TYPE_EDIT); } else { addMediaLogEntry($new, $id, DOKU_CHANGE_TYPE_CREATE, $lang['created']); } return $id; } else { return array($lang['uploadfail'], -1); } }
protected function delete_media_file($project_path) { global $ID; $id = getNS($ID) . ':' . $this->name; $media_path = mediaFN($id); if (file_exists($media_path)) { media_saveOldRevision($id); unlink($media_path); } }