myGully.com

myGully.com (https://mygully.com/index.php)
-   Entwicklung & Programmierung (https://mygully.com/forumdisplay.php?f=72)
-   -   GELÖST! PHP: pecl-install-fileinfo (https://mygully.com/showthread.php?t=2864424)

Firefox64 09.03.13 19:47

GELÖST! PHP: pecl-install-fileinfo
 
Olla!

Ich möchte Uploads prüfen.
Dazu möchte ich die PHP erweiterung pecl-fileinfo nutzen.

Ich habe die Erweiterung wie folgt installiert:

Zitat:

Download the source and install ‘fileinfo’.

1. Execute the following lines one by one.

wget [Link nur für registrierte und freigeschaltete Mitglieder sichtbar. Jetzt registrieren...]
tar -zxf Fileinfo-1.0.3.tgz
cd Fileinfo-1.0.3
phpize
./configure && make && make install

2. Add the extension in PHP configuration file. You can find it using the command “php -i | grep ini“.

extension=fileinfo.so >> <full-path>/php.ini

3. Restart Apache service.
# php -m | grep file
gibt auch file info aus die Erweiterung ist also richtig installiert...?

Der Betrefende Quelltext:
PHP-Code:

        if( isset($_FILES["uploadfile"]) )  //Prüft ob die datei überhaupt exestiert und ob sie ordnungsgemäß hochgeladen wurde.
        
{
                    
            
$Info = new finfo("magic");    
            
$FileType $Info->file($_FILES["uploadfile"]["tmp_name"]);
            
/*
             * Mögliche Dateitypen auf die geprüft wird:
             * Bilder (PNG, JPEG, GIF, TIFF, BMP,)
             * TEXT/Plain
             * PDF
             * MSWORD
             * Gepackte daten werden aufgrund der gefahr von ZipBomben nicht berücksichtigt...
            
            
            
             switch($FileType)
             {
                 case "image/jpeg":
                    echo "es handelt sich um eine jpeg Datei";
                     
                     break;
             }
             
             */
            
echo "UPload erfolgreic$file = file($_FILES["uploadfile"]);
            
            print 
$finfo->file($file, FILEINFO_MIME) . "\r\n";
            print 
$finfo->file($file, FILEINFO_MIME_TYPE) . "\r\n";
            print 
$finfo->file($file, FILEINFO_MIME_ENCODING) . "\r\n";h";
        }
        else {
            echo 
"Fehler beim Hochladen! Versuche die Seite neu zu laden oder versuche es zu einem Späteren Zeitpunkt erneut!";
        }
        
        
move_uploaded_file($_FILES['uploadfile']['tmp_name'], "hochgeladene_daten/uplaod.txt");  //Kopiert die Datei an den Enstprechnden Ort
                
        
echo "test"

Ich bekomme keine ausgabe...
Einer ne Idee was ich falsch mache?

edit:
Weißte da grübelst du anderthalb stunden und kaum stellste die frage hat es sich erledigt...
Für den Fall das mal einer per google hier herfindet:

finfo() ist seit php5.3 in php intigriert!
Hier mal ein Democode:

PHP-Code:

$finfo = new finfo();
            
$file "/home/user/testbild.jpg";
            print 
$finfo->file($fileFILEINFO_MIME) . "\r\n";
            print 
$finfo->file($fileFILEINFO_MIME_TYPE) . "\r\n";
            print 
$finfo->file($fileFILEINFO_MIME_ENCODING) . "\r\n";$finfo = new finfo(); 

edit2: Wie schließt man nocmal themen.. *SChähm*:confused:


Alle Zeitangaben in WEZ +1. Es ist jetzt 05:37 Uhr.

Powered by vBulletin® (Deutsch)
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.