【问题标题】:how to get length of audio file in codeigniter while upload file上传文件时如何在codeigniter中获取音频文件的长度
【发布时间】:2017-01-07 05:49:28
【问题描述】:

我有一个与文件上传相关的问题, 我想以分钟为单位获取音频文件的持续时间长度。 在上传该文件时,我可以获得所有详细信息,例如大小、类型、最大长度、文件名,但不能获得该音频文件的持续时间。

$config['upload_path'] = './uploads/songs/';
$config['allowed_types'] = 'gif|jpg|png|mov|mp3|aiff|mpeg|zip';
$config['max_size'] = '30000';
$config['max_width'] = '1024';
$config['max_height'] = '1024';
$config['file_ext_tolower'] = 'TRUE';
$config['remove_spaces'] = TRUE;
$this->load->library('upload', $config);
$uploadSong = $this->upload->data();
print_r($uploadSong); 

在 print_r 得到上传文件的输出之后

Array ( 
  [file_name] => song_one1.mp3 
  [file_type] => application/octet-stream 
  [file_path] => C:/xampp/htdocs/rockherogame/uploads/songs/         
  [full_path] => C:/xampp/htdocs/rockherogame/uploads/songs/song_one1.mp3 
  [raw_name] => song_one1 
  [orig_name] => song_one.mp3 
  [client_name] => song_one.mp3 
  [file_ext] => .mp3 
  [file_size] => 4059.28 
  [is_image] => 
  [image_width] => 
  [image_height] => 
  [image_type] => 
  [image_size_str] => )

请帮助我了解如何获取文件的持续时间?

提前致谢

【问题讨论】:

  • 如何在codeigniter中使用这个

标签: php codeigniter file-upload


【解决方案1】:

这应该对你有用,注意 getduration 函数:http://www.zedwood.com/article/127/php-calculate-duration-of-mp3

【讨论】:

    【解决方案2】:

    需要计算音频文件的持续时间。

    这是一个很好的例子,展示了如何在 php 中做同样的事情

    http://www.zedwood.com/article/127/php-calculate-duration-of-mp3

    您也可以安装和使用getid3。 代码 sn-p here

    【讨论】:

      猜你喜欢
      • 2021-02-03
      • 1970-01-01
      • 2020-08-17
      • 1970-01-01
      • 1970-01-01
      • 2016-06-19
      • 2020-03-18
      • 1970-01-01
      • 2016-04-23
      相关资源
      最近更新 更多