summaryrefslogtreecommitdiff
path: root/actions/newnotice.php
diff options
context:
space:
mode:
authorZach Copley <zach@controlyourself.ca>2009-06-22 22:48:31 +0000
committerZach Copley <zach@controlyourself.ca>2009-06-22 22:48:31 +0000
commitd9bebfd6512353690be8bf8cc596a0656ef48ae9 (patch)
tree774a6e3338fbc09082fcf02f83b272ace0c2c524 /actions/newnotice.php
parentf95dbee7d6ddaca6fcbf159fb80f76ccaf1f9baa (diff)
Attachment upload server and path now configurable
Diffstat (limited to 'actions/newnotice.php')
-rw-r--r--actions/newnotice.php34
1 files changed, 27 insertions, 7 deletions
diff --git a/actions/newnotice.php b/actions/newnotice.php
index 72ccd8c32..09652d2b3 100644
--- a/actions/newnotice.php
+++ b/actions/newnotice.php
@@ -257,23 +257,43 @@ class NewnoticeAction extends Action
}
function storeFile($notice, $mimetype) {
- $filename = basename($_FILES['attach']['name']);
- $destination = "file/{$notice->id}-$filename";
- if (move_uploaded_file($_FILES['attach']['tmp_name'], INSTALLDIR . "/$destination")) {
+
+ common_debug("NewnoticeAction::storeFile()");
+
+ $basename = basename($_FILES['attach']['name']);
+
+ common_debug("Basename: $basename");
+
+ $filename = File::filename($notice->id, $basename);
+
+ common_debug("filename: $filename");
+
+ $filepath = File::path($filename);
+
+ common_debug("filepath: $filepath");
+
+ if (move_uploaded_file($_FILES['attach']['tmp_name'], $filepath)) {
+
$file = new File;
+ $file->filename = $filename;
+
$file->url = common_local_url('file', array('notice' => $notice->id));
- $file->size = filesize(INSTALLDIR . "/$destination");
+
+ common_debug("file->url =". $file->url);
+
+ $file->size = filesize($filepath);
$file->date = time();
$file->mimetype = $mimetype;
+
if ($file_id = $file->insert()) {
$file_redir = new File_redirection;
- $file_redir->url = common_path($destination);
+ $file_redir->url = File::url($filename);
$file_redir->file_id = $file_id;
$file_redir->insert();
$f2p = new File_to_post;
- $f2p->file_id = $file_id;
- $f2p->post_id = $notice->id;
+ $f2p->file_id = $file_id;
+ $f2p->post_id = $notice->id;
$f2p->insert();
} else {
$this->clientError(_('There was a database error while saving your file. Please try again.'));