如何上传音频(mp3歌曲)?

时间:2015-11-03 19:58:44

标签: php audio upload mp3

  1. 请帮我上传音频文件的PHP / HTML代码。通过许多代码上传图像,但在音频的情况下失败。
  2. 我通过一些博客来达到下面给出的特定代码,仅用于上传较小尺寸的文件。(在大小约为3mb的mp3的情况下失败)。
  3. 代码:

    <form name="audio_form" id="audio_form" action="" method="post" enctype="multipart/form-data">
    <fieldset>
    <label>Audio File:</label>
    <input name="audio_file" id="audio_file" type="file"/>
    <input type="submit" name="Submit" id="Submit" value="Submit"/>
    </fieldset>
    </form>
    <?php
    
    if(isset($_POST['Submit']))
    {
    $file_name = $_FILES['audio_file']['name'];
    
    if($_FILES['audio_file']['type']=='audio/mpeg' || $_FILES['audio_file']['type']=='audio/mpeg3' || $_FILES['audio_file']['type']=='audio/x-mpeg3' || $_FILES['audio_file']['type']=='audio/mp3' || $_FILES['audio_file']['type']=='audio/x-wav' || $_FILES['audio_file']['type']=='audio/wav')
    { 
     $new_file_name=$_FILES['audio_file']['name'];
    
     // Where the file is going to be placed
     $target_path = "audios/".$new_file_name;
    
     //target path where u want to store file.
    
     //following function will move uploaded file to audios folder. 
    if(move_uploaded_file($_FILES['audio_file']['tmp_name'], $target_path)) {
    echo "hello";
     //insert query if u want to insert file
    }
    }
    }
    ?>
    

0 个答案:

没有答案