How to create a folder in php and soon after launch exec?

0

I need to create a folder and right after launching the thumbnail created on it.

mkdir(pasta, 0777. true);

if(a pasta recém criada existir ){
   exec("ffmpeg -i ".$currentPath." -vf fps=1/60 " .$pasta_recem_criada."/thumb%03d.png", $output, $return);
}
    
asked by anonymous 04.02.2018 / 02:00

1 answer

0

Use the return of the mkdir function itself to verify that the folder has been created. Ex:

<?php

$folderClip = "clip";
$folderVideos = "~/Videos"

/**
 * Tenta criar a pasta, caso a pasta seja criada
 * retorna 'true' e então executa a função 'exec'
 * caso contrário, "pula" o código.
 */
if (mkdir($pasta, 0777, true)) {
    exec("ffmpeg -i {$folderVideos}/papa_mike.mp4 -vframes 1 {$folderClip}/papa_mike.png", $output, $return);
}
  

Note: If your file is in the project root, it is not necessary to pass the current folder.

    
04.02.2018 / 12:55