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

Asked

Viewed 176 times

1

I need to create a folder and right after launching the thumbnail created in 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);
}
  • if (is_dir("caminho/da/pasta") === true || is_file("caminho/da/pasta") === true) { exec() }

1 answer

1


Use the function’s own return mkdir to check if the folder was 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: In case your file is at the root of the project, it is not necessary to pass the current folder.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.