top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration

Facebook Login
Site Registration

video upload sample code in php?

+2 votes


Can any one provide me sample code or links for video upload and retrieve and play in php.

Database is mySQL

posted Oct 13, 2014 by Vrije Mani Upadhyay

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

The script handles the upload form and uploads the video. You will need to provide valid tokens for your account, replacing [[READ_TOKEN]] and [[WRITE_TOKEN]] with your own tokens.

Code for the form:

    <title>File Upload Form</title>
    <h2>This form allows you to upload a Video to the Brightcove Video Cloud.</h2>
    <form action="BCLuploadVideo.php" method="post" enctype="multipart/form-data"><br>
      <p>Video Name: <input type="text" name="bcVideoName" size="50" /></p>
      <p>Video Description:<br/><textarea name="bcShortDescription" rows="5" cols="50"></textarea></p>
      <p>Type (or select) Filename: <input type="file" name="videoFile"></p>
      <p><input type="submit" value="Upload File"></p>

Code for the PHP script:


  // This code example uses the PHP Media API wrapper
  // For the PHP Media API wrapper, visit

  // Include the BCMAPI Wrapper

  // Instantiate the class, passing it our Brightcove API tokens (read, then write)
  $bc = new BCMAPI(

  // Create an array of meta data from our form fields
  $metaData = array(
    'name' => $_POST['bcVideoName'],
    'shortDescription' => $_POST['bcShortDescription']

  // Move the file out of 'tmp', or rename
  rename($_FILES['videoFile']['tmp_name'], '/tmp/' . $_FILES['videoFile']['name']);
  $file = '/tmp/' . $_FILES['videoFile']['name'];

  // Create a try/catch
  try {
    // Upload the video and save the video ID
    $id = $bc->createMedia('video', $file, $metaData);
          echo 'New video id: ';
          echo $id;
  } catch(Exception $error) {
    // Handle our error
    echo $error;
answer Oct 16, 2014 by Rahul Singh
Similar Questions
0 votes

I have php script form which I used to input Members Details of my system into the MySQL database. My requirement is to display the last member's details in a input box.

Contact Us
+91 9880187415
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Karnataka INDIA.