0

谁能告诉我如何通过 ajax 调用在服务器上存储 blob?我尝试了很多东西,但没有一个有效。而且我找不到任何关于此的好信息。

这是我要发送 blob 的地方

class Ajax extends CI_Controller {

function __construct()
{
    parent::__construct();
    $this->load->helper('url');
    $this->load->helper('form_helper');
    $this->load->library('tank_auth');

}

public function saverecording()
{
    $status = "";
    $msg = "";
    $file_element_name = 'komaan';
    if ($status != "error")
    {
          $config['upload_path'] = '../../upload/audio/recordings/';
          $config['allowed_types'] = 'wav';
          $this->load->library('upload', $config);
          if (!$this->upload->do_upload($file_element_name))
          {
             $status = 'error';
             $msg = $this->upload->display_errors('', '');
             echo '<script>
             console.log("this is not working");</script>';
          }
          else
          {
             $data = $this->upload->data();
             echo '<script>
             console.log("this is ");</script>';
             //$file_id = $this->files_model->insert_file($data['file_name'], $_POST['title']);
          }
          @unlink($_FILES[$file_element_name]);
       }
}

新编辑:感谢您的耐心,我对网络开发很陌生。我弄清楚了问题所在。正如我所说,我从 javascript 代码中获得了一个 blob 文件:

recorder.exportWAV(function(blob) {
            console.log(blob);
            $('userfile').val(blob);
            $.ajaxFileUpload({
            url :  "../ajax/saverecording/", 
            secureuri      :false,
            fileElementId  :'userfile',
                dataType : blob.type,
                data: blob,
                success: function(data, status) {
                    if(data.status != 'error')
                        alert("hoera!");
                    alert(data.msg);
                }
            });
        });

$('userfile').val(blob); 给我一个“未捕获的错误:InvalidStateError:DOM Exception 11”为什么?

谢谢

卡特里妮

4

0 回答 0