Send audio file to server - PHP



Let's send the audio file to the server using php. As logic, send an audio file to php at post from html form. php will receive it and send it to the server using the move_uploaded_file function. Before executing the move_uploaded_file function, use if to judge whether the sent file is an audio file. The whole code looks like this

class AudioFile 
    function check_audio_type()
$updir = "./upload/";
$filename = $_FILES['upmusic']['name'];
echo $_FILES['upmusic']['type'];

if ($_FILES['upmusic']['type'] == "audio/wav") 
        if(move_uploaded_file($_FILES['upmusic']['tmp_name'], $updir.$filename)==FALSE)
          print("Upload faild");

$audio_file  = new AudioFile ();

As for the implementation of the part that sends the audio file to the server, the sample code is posted in Qiita below, so I think that you can grasp the movements by reading it.

[urlpreviewbox url=""/]

LinkedIn にシェア


Copyright© , 2021 All Rights Reserved Powered by AFFINGER5.