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 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?