Upload.class.php

gehe zur Dokumentation dieser Datei
00001 <?php
00002 // ---------------------------------------------------------------------------
00003 // $Id$
00004 // ---------------------------------------------------------------------------
00005 // OpenRat Content Management System
00006 // Copyright (C) 2002-2004 Jan Dankert, jandankert@jandankert.de
00007 //
00008 // This program is free software; you can redistribute it and/or
00009 // modify it under the terms of the GNU General Public License
00010 // as published by the Free Software Foundation; either version 2
00011 // of the License, or (at your option) any later version.
00012 //
00013 // This program is distributed in the hope that it will be useful,
00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 // GNU General Public License for more details.
00017 //
00018 // You should have received a copy of the GNU General Public License
00019 // along with this program; if not, write to the Free Software
00020 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00021 // ---------------------------------------------------------------------------
00022 // $Log$
00023 // Revision 1.5  2007-11-22 21:20:21  dankert
00024 // Fehlerhandling, wenn Upload misslingt.
00025 //
00026 // Revision 1.4  2007-10-25 22:28:18  dankert
00027 // Filemanager f?r den FCK-Editor mit Zugriff auf OpenRat-Verzeichnis.
00028 //
00029 // Revision 1.3  2007-10-02 21:13:44  dankert
00030 // Men?punkt "Neu" mit direktem Hinzuf?gen von Objekten.
00031 //
00032 // Revision 1.2  2004/05/02 15:04:16  dankert
00033 // Einfügen package-name (@package)
00034 //
00035 // Revision 1.1  2004/04/24 17:03:28  dankert
00036 // Initiale Version
00037 //
00038 // Revision 1.1  2003/10/27 23:21:55  dankert
00039 // Methode(n) hinzugefügt: savevalue(), save()
00040 //
00041 // ---------------------------------------------------------------------------
00042 
00050 class Upload
00051 {
00052      var $filename;
00053      var $extension;
00054      var $value;
00055      var $size;
00056      var $error  = '';
00057 
00058      
00064      function isValid()
00065      {
00066           return empty($this->error);
00067      }
00068      
00069      
00070      
00077      function Upload( $name='file' ) // Konstruktor
00078      {
00079           global $FILES;
00080 
00081           if   ( !isset($FILES[$name])              || 
00082                  !isset($FILES[$name]['tmp_name'])  ||
00083                  !is_file($FILES[$name]['tmp_name'])   )
00084           {
00085                $this->error = 'No file received.';
00086                return;
00087           }
00088                
00089           $this->size = filesize($FILES[$name]['tmp_name']);
00090           
00091           $fh    = fopen( $FILES[$name]['tmp_name'],'r' );
00092           
00093           $this->value = fread($fh,$this->size);
00094           fclose( $fh );
00095      
00096           $this->filename = $FILES[$name]['name'];
00097           $this->extension = '';
00098 
00099           $p = strrpos( $this->filename,'.' ); // Letzten Punkt suchen
00100 
00101           if   ($p!==false) // Wennn letzten Punkt gefunden, dann dort aufteilen
00102           {
00103                $this->extension = substr( $this->filename,$p+1 );
00104                $this->filename  = substr( $this->filename,0,$p );
00105           }
00106      }
00107 }
00108 
00109 ?>

Erzeugt am Thu May 14 00:55:49 2009 für OpenRat von  doxygen 1.5.8