" method="post" onsubmit="if (this.mid_upload.value==''){alert('Please choose a mid-file to upload!');return false}">
<div>
<input type="hidden" name="MAX_FILE_SIZE" value="1048576" /><!-- 1 MB -->
MIDI file (*.mid) to upload: <input type="file" name="mid_upload" />
<br /><br />
<input type="submit" value=" send " />
</div>
</form>
<?php 
if (@$file) {
    /****************************************************************************
    	MIDI CLASS CODE
    	****************************************************************************/
    require './classes/midi_duration.class.php';
    $midi = new MidiDuration();
    $midi->importMid($file);
    echo '<div style="margin-top:20px">Duration [sec]: ' . $midi->getDuration() . '</div>';
    #	$midi = new Midi();
    #	$midi->importMid($file);
    #
    #	$maxTime=0;
    #	foreach ($midi->tracks as $track){
    #		$msgStr = $track[count($track)-1];
    #		list($time)=explode(" ", $msgStr);
    #		$maxTime=max($maxTime,$time);
    #	}
    #	$duration=$maxTime * $midi->getTempo() / $midi->getTimebase() / 1000000;
    #	echo "Duration [sec]: $duration"; // ergibt 69.0623480625 sec für bossa.mid
}
?>
</body>
 private function getDurationStr($pathToFile)
 {
     if (!$this->isPolytone) {
         $pathToFile = escapeshellcmd($pathToFile);
         $retorno = exec("ffmpeg -i {$pathToFile} 2>&1 | grep \"Duration\" | cut -d ' ' -f 4 | sed s/,//", $lines, $returnCode);
         if (!$returnCode) {
             return substr($retorno, 0, -3);
         } else {
             $this->addLog("No se pudo obtener la duracion del realtone\n");
             $this->genException("CRIT", __LINE__, __METHOD__, ": No se pudo obtener la duracion del realtone" . $this->uniqueId);
         }
     } else {
         $midi = new MidiDuration();
         $midi->importMid($pathToFile);
         return $midi->getDuration();
     }
 }