• Skip to primary navigation
  • Skip to content
  • Skip to primary sidebar
VdoCipher: Secure Video Hosting for BusinessVdoCipher
☰
Sign Up
  • Features
  • Pricing
  • Testimonials
  • About
  • Contact
Login
Sign Up

PHP sample video upload from browser to VdoCipher

October 2, 2022 /

[This article is based on API v2 as documented here.]

The Upload API workflow and overview can be found here.

Please find below a sample code for enabling video upload from your PHP website’s users. Note that this is sample code and you will need to configure it according to the controller-view structure in your application. It is not a recommended to put Controller logic and HTML output in a single file.

https://gist.github.com/vibhavsinha/71d394132a98c049f8aa

<?php
function send($action, $params, $posts = false){
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_RETURNTRANSFER,true);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
    $getData = http_build_query($params);
	$postData = ['clientSecretKey'=>'CLIENT_SECRET_KEY'];            ////Replace the caps CLIENT_SECRET_KEY with your video id.
    if ($posts) {
		$postData = http_build_query(array_merge($postData, $posts));
	}
    curl_setopt($curl, CURLOPT_POST, true); 
    curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
    $url = "http://api.vdocipher.com/v2/$action/?$getData";
    curl_setopt($curl, CURLOPT_URL,$url);
    $html = curl_exec($curl);
    curl_close($curl);
    return $html;
}

$upload_data = json_decode(send('uploadPolicy', [], ['title'=>'NEW_TITLE']), true);
if (is_null($upload_data)) {
	throw new Exception('Exception: ' . $upload_data);
}
?>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  </head>
  <body>

  <form action="<?= $upload_data['upload_link_secure'] ?>" method="post" enctype="multipart/form-data">
    Key to upload: 
	<input type="hidden"  name="key" value="<?= $upload_data['key'] ?>" /><br />
	<input type="hidden" name="success_action_status" value="201" />
	<input type="hidden" name="success_action_redirect" value="https://www.vdocipher.com" />

	<input type="hidden"   name="X-Amz-Credential" value="<?= $upload_data['x-amz-credential'] ?>" />
	<input type="hidden"   name="X-Amz-Algorithm" value="<?= $upload_data['x-amz-algorithm'] ?>" />
	<input type="hidden"   name="X-Amz-Date" value="<?= $upload_data['x-amz-date'] ?>" />

	<input type="hidden" name="Policy" value='<?= $upload_data['policy'] ?>' />
	<input type="hidden" name="X-Amz-Signature" value="<?= $upload_data['x-amz-signature'] ?>" />
    File: 
    <input type="file"   name="file" /> <br />
    <!-- The elements after this will be ignored -->
    <input type="submit" name="submit" value="Upload to Amazon S3" />
  </form>
</html>

When setting up your front-end, you will like to enable better interface with AJAX upload such that your user’s can have a seamless experience. For this it is recommended to use one of the available libraries(angularjs, jquery or standalone, etc.) . Note that all these can be modified to be used in this set up. You can also see a sample implementation of the angular’s ng-file-upload library in your vdocipher dashboard itself.

Supercharge Your Business with Videos

At VdoCipher we maintain the strongest content protection for videos. We also work extremely hard to deliver the best viewer experience. We'd love to hear from you, and help boost your video streaming business.

Free 30-day trial →

Filed Under: APIs and Sample Codes, PHP, Using VdoCipher Tagged With: php upload api, php video api

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar



Secure Your Videos

Blog Categories

  • DRM 
  • APIs and Sample Codes
  • WordPress
  • E-learning
  • Media
  • Video Tech
  • Portuguese
  • Spanish
  • Arabic

Popular Posts

  • Google Widevine DRM 
  • WordPress video plugin: Add Secure Videos to your WP site
  • Understanding Video Quality – Pixels (p), Bitrate (kbps), Aspect Ratios
  • Add text to video with dynamic watermarking
  • Encrypted Video Streaming: VdoCipher & Others
  • Video Hosting For Online Courses
  • Video Quality: What is Video Bitrate, Pixel & Aspect Ratios 
  • Online Video Player
  • Apple Fairplay DRM
  • Study Apps For Students
  • SVOD VS TVOD VS AVOD
  • DRM Security
  • Exoplayer Tutorial
  • Video Platform Comparison

Recent Top Post

  • Enterprise Video Platform
  • Cloud Video Platform
  • Shaka Player
  • Install FFMPEG on Windows
  • Video Aspect Ratio
  • Video Streaming Protocols
  • Adaptive Bitrate Streaming
  • Elearning Statistics 2021
  • DRM Solution
  • Video Bitrate
  • History Of Youtube
  • React Native Video
  • Video Piracy
Recent Blogs
  • The History of Netflix- Founding, Model, Timeline, Milestones (2023 Updated)
  • Google Widevine DRM: Simple Guide to Security & Integration
  • Closed Captions vs Subtitles differences, formatting and working
  • What is Video Resolution, Types, Advantages & Disadvantages
  • E-learning Video Creation: 31 Tips and Techniques for Engaging Online Courses
  • Flutter Video Player with Secure Flutter Video Plugin or SDK
  • Comparing The Top 7 VOD Platform Providers For Video Hosting
  • Top 19 Video Streaming Platforms & hosting providers [Updated 2023]
Popular Blogs
  • How many use easy video download piracy tools ?
  • Apple FairPlay DRM: Video Protection on iOS & Safari
  • 12 Video Piracy Statistics, 6 Prevention Methods
  • Elearning Video Protection: Ensure Piracy Protection of Your Videos
Navigation
  • Home
  • Glossary
  • Features
  • About Us
  • Pricing
  • FAQs
  • Terms
  • Privacy Policy
  • Contact US
Industry
  • Education and Training
  • Media and Entertainment
  • DRM and Antipiracy
  • APIs for Developers
  • Video Hosting and Marketing
  • Widevine DRM
  • Video DRM
  • Google DRM
  • DRM license Server
  • Custom Video Player
  • <
Follow Us
We are Amazon AWS Technology Partner for Secure Video Hosting for Business
We use Akamai CDN for Secure Video Streaming for Business

© 2023 VdoCipher Media Solutions Pvt. Ltd.