Two way to see type of file

Discussion in 'PHP' started by piropeator, Jun 1, 2016.

  1. #1
    Hi. I have this:
    <!DOCTYPE html>
    <html lang="es">
    <head>
        <meta charset="UTF-8">
        <title>Document</title>
    </head>
    <body>
        <form name="cargar" action="VerTipoFileShow.php" method="POST" enctype="multipart/form-data">
                <input type="file" name="archivo" size="2"></input>
                <input type="submit" value="Cargar Archivo"></input>
        </form>   
    </body>
    </html>
    HTML:
    I want to see the type of file using $_FILES[] and using FINFO_FILE();
    <?php
    echo "Tipo usando FILES :".$_FILES['archivo']['type'];
    echo "<br/>";
    
    $finfo = finfo_open(FILEINFO_MIME_TYPE);
    $filename = $_FILES['archivo']['name'];
    
    echo "Tipo usando FINFO:".finfo_file($finfo, $filename);
    ?>
    PHP:
    But I get this message:
    Warning: finfo_file(file.ext): failed to open stream: No such file or directory in Show.php on line 8
    Code (markup):
    What is the problem?
    Note: fileinfo is enabled.
     
    Solved! View solution.
    piropeator, Jun 1, 2016 IP
  2. #2
    hdewantara, Jun 1, 2016 IP