I have a converterShell class and i need to call it from controller. the command will convert a video. when i tested from the cmd, it worked, but i need to call after my file is moved to the upload folder. I thought of put the "call" on a function and call when the filme is already moved. But the problem is to call the shell class. Here are the codes:
class ConverterShell extends AppShell {
public function main() {
shell_exec('cd webroot\files\ && ffmpeg -i ' .fonte. 'whatever.wmv ' .destino. 'BLABLABLA.mp4');
}
aaaand
public function arquivos() {
$this->autoRender = false;
$name = $this->request->params['form']['upload']['name'];
$type = $this->request->params['form']['upload']['type'];
$tmp_name = $this->request->params['form']['upload']['tmp_name'];
$error = $this->request->params['form']['upload']['error'];
$size = $this->request->params['form']['upload']['size'];
$path_parts = pathinfo($name);
$formato = ($path_parts['extension']);
$nome = ($path_parts['filename']);
$tamanho = ((($size)/1024)/1024);
$tamanho_mb = number_format($tamanho, 2, '.', '');
$string = $name;
echo iconv('UTF-8', 'ISO-8859-1//TRANSLIT//IGNORE', $string);
if(!$error) {
if(move_uploaded_file($tmp_name, WEBROOT_FOLDER . 'files/uploads/' . $name)) {
$this->call function here();
exit('OK!');
} else {
exit('Erro!');
}
}
}