title: How to find wav file duration in php before uploading?
body: <p>I need to get the wav file duration in php. I know there are lots of code examples available for this issue. I have used this one.</p>
  
  <pre><code>function wavDur($file) {
      $fp = fopen($file, 'r');
      if (fread($fp,4) == "RIFF") {
          fseek($fp, 20);
          $rawheader = fread($fp, 16);
          $header = unpack('vtype/vchannels/Vsamplerate/Vbytespersec/valignment/vbits',$rawheader);
          $pos = ftell($fp);
          while (fread($fp,4) != "data" &amp;&amp; !feof($fp)) {
              $pos++;
              fseek($fp,$pos);
          }
          $rawheader = fread($fp, 4);
          $data = unpack('Vdatasize',$rawheader);
          $sec = $data[datasize]/$header[bytespersec];
          $minutes = intval(($sec / 60) % 60);
          $seconds = intval($sec % 60);
          return str_pad($minutes,2,"0", STR_PAD_LEFT).":".str_pad($seconds,2,"0", STR_PAD_LEFT);
      }
  </code></pre>
  
  <p>But the problem is that I need the file path the file control doesn't allow me to get the full path I want to show the duration to the user before uploading just when the user have selected the file. Is this possible?</p>