function addAttachment($local_file, $filename, $description){ $attachment = new SI_Attachment(); $filename = $attachment->save($local_file, $filename); if($filename === FALSE){ $this->error = "SI_Project::addAttachment(): ".$attachment->getLastError()."\n"; return FALSE; } $attachment->project_id = $this->id; $attachment->description = $description; $attachment->path = $filename; if($attachment->add() === FALSE){ $this->error = "SI_Project::addAttachment(): ".$attachment->getLastError()."\n"; return FALSE; } if($this->_populateAttachments() === FALSE) return FALSE; return TRUE; }
* the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * http://www.gnu.org/copyleft/gpl.html * */ require_once('includes/common.php'); checkLogin(); require_once('includes/SI_Attachment.php'); // Get the data $attachment = new SI_Attachment(); if($attachment->get($_REQUEST['id']) === FALSE){ fatal_error("Error getting attachment!"); } header("Content-type: application/octet-stream" ); header('Content-Disposition: attachment; filename="'.$attachment->path.'"'); readfile($GLOBALS['CONFIG']['attachment_dir'].$attachment->path); ?>