- function storeFile($notice) {
- $filename = basename($_FILES['attach']['name']);
- $destination = "file/{$notice->id}-$filename";
- if (move_uploaded_file($_FILES['attach']['tmp_name'], INSTALLDIR . "/$destination")) {
- $file = new File;
-// $file->url = common_local_url('file', array('notice' => $notice->id));
- $file->url = common_path($destination);
- $file->size = filesize(INSTALLDIR . "/$destination");
- $file->date = time();
- $file->mimetype = $_FILES['attach']['type'];
- if ($ok = $file->insert()) {
- $f2p = new File_to_post;
- $f2p->file_id = $ok;
- $f2p->post_id = $notice->id;
- $f2p->insert();
- } else {
- die('inserting file, dying');
- }
- }
-/*
- $url = common_local_url('file', array('notice' => $notice->id));
- echo "$destination<br />";
- die($url);
-*/
- }
-
-
- /** save all urls in the notice to the db
- *
- * follow redirects and save all available file information
- * (mimetype, date, size, oembed, etc.)
- *
- * @param class $notice Notice to pull URLs from
- *
- * @return void
- */
- function saveUrls($notice, $uploaded = null) {
- common_replace_urls_callback($notice->content, array($this, 'saveUrl'), $notice->id);
- }
-
- function saveUrl($data) {
- list($url, $notice_id) = $data;
- $zzz = File::processNew($url, $notice_id);
- }
-