doskmc7870 2015-12-22 11:40
浏览 56
已采纳

使用PHP过滤上传到音频

Sorry I'm quite a noob to PHP and I want to know how I can filter an upload so that it echo's out in an audio file for e.g. I want to upload an Mp4 file so that when I submit it - it echo's in an audio HTML5 tag.

I tried my version which resulted in the udio output flashing for a couple of second before fading out again.

enter image description here

Thank you very much and sorry if I haven't explained too well.

  • 写回答

1条回答 默认 最新

  • doulao3078 2015-12-22 12:02
    关注

    It's very simple

    <?php
        if(isset($_FILES['file'])){//check if isset file
            $errors= array();
            $file_name = $_FILES['file']['name'];//set file name
            $file_tmp =$_FILES['file']['tmp_name'];//get file temp path
            $path ="files/".$file_name;//set file name with path you have to create a directory name files & have write permission if ubuntu
    
            if(empty($errors)==true){
                move_uploaded_file($file_tmp,$path);//move the uploaded file to destination from temp path
            }
        }
    ?>
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title></title>
    </head>
    <body>
    <!--file upload form-->
    <form action="" method="POST" enctype="multipart/form-data">
        <input type="file" name="file" />
        <input type="submit"/>
    
    </form>
    <?php
        if(isset($path))//check if you have path variable set
        {
    ?>
            <!--render audio player-->
            <audio controls>
                <source src="<?php echo $path ?>" type="audio/mpeg">
                Your browser does not support the audio element.
            </audio>
    <?php
        }
    ?>
    
    </body>
    </html>
    

    check this links for file upload http://www.tutorialspoint.com/php/php_file_uploading.htm http://php.net/manual/en/features.file-upload.php http://www.w3schools.com/php/php_file_upload.asp

    & this for HTML5 audio http://www.w3schools.com/html/html5_audio.asp

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊
  • ¥15 安装svn网络有问题怎么办