Welcome Guest, Not a member yet? Register   Sign In
File upload with HtmlWebRequest on server [works on localhost]
#1

Hello,

I have a site where a user records a video of himself, which is directly captured from the camerafeed and then sent via xhr to the backend to be saved.

This works perfectly on localhost (Xampp on windows), but it does not work when I run the exact same code on the server.



XHR code:

Code:
media_recorder.addEventListener('stop', function() {
    // create local object URL from the recorded video blobs
    console.log('recording stopped');
      var f = new FormData();
      f.append('videofile', new Blob(blobs_recorded));
      f.append('renter_id', '<?php echo $rent['id'];?>');
      f.append('type', 'verification');
   
      var xhr=new XMLHttpRequest();

      xhr.open('POST','<?php echo base_url();?>/objects/save_video',false);
      xhr.send(f);
      window.location.replace("<?php echo base_url();?>/objects/verify_renter_done/<?php echo $rent['id'];?>");
      });


Upload code:
PHP Code:
function save_video() 
        {
            $session = \Config\Services::session();
            $code $session->get('code');
            $renter_id $this->request->getPost('renter_id');
            $type $this->request->getPost('type');
            $video $this->request->getFile('videofile');
            
            
//$fileData = file_get_contents($video['tmp_name']);
            $new_name 'verification.webm';
            $filepath FCPATH ."uploads/$code/$renter_id/";
            $video->move($filepath,$new_name);

        

Error:

[Image: 4L4ycTT.png]

PHP Code:
On my development PC (Windows 10with Xampp), the code works fine.
On my live server (Centos8 with apacheit doesnt...

Any help would be greatly appreciated 
Reply


Messages In This Thread
File upload with HtmlWebRequest on server [works on localhost] - by MBVape64 - 06-18-2021, 05:17 PM



Theme © iAndrew 2016 - Forum software by © MyBB