I have an application were by users can upload images and should be able to echo and play videos. My upload function works fine but challenge that i am having now is to echo and play the video. Here is how i am uploading the file
function uploadFile() {
$file = $this->data['CpdVideo']['file'];
if ($file['error'] === UPLOAD_ERR_OK) {
$id = String::uuid();
if (move_uploaded_file($file['tmp_name'], WWW_ROOT . 'files/videos/' . $file['name'])) {
$this->request->data['CpdVideo']['filename'] = $file['name'];
$this->request->data['CpdVideo']['filesize'] = $file['size'];
$this->request->data['CpdVideo']['filemime'] = $file['type'];
return true;
}
}
return false;
}
Here is how i am saving the video
if ($this->uploadFile() && $this->CpdVideo->save($this->data))
This how i echo and play the video in my view.ctp. Please not this edited code and this works for me now
<object width="100" height="100">
<param name="movie" value="<?php echo $this->Html->url('/files/videos/'. $cpdVideo['CpdVideo']['filename'])?>">
<embed src="<?php echo $this->Html->url('/files/videos/'. $cpdVideo['CpdVideo']['filename'])?>" width="100" height="100">
</embed>
</object>
If any one could help me out that would be awesome