enable parallel jobs

This commit is contained in:
Pierre Guillod 2023-07-06 00:55:14 +02:00
parent 9641fcf7a4
commit f2dc81f477
Signed by: pierre
GPG key ID: 78018D943E9CBD0C

View file

@ -2,11 +2,14 @@
$fromExt = strtolower(pathinfo($_FILES["file"]["name"])['extension']); $fromExt = strtolower(pathinfo($_FILES["file"]["name"])['extension']);
$toExt = $_POST["submit"]; $toExt = $_POST["submit"];
$targPat = "/var/www/uploads/upload.$fromExt"; $jobId = bin2hex(random_bytes(16));
$targPat = "/var/www/uploads/$jobId/upload.$fromExt";
move_uploaded_file($_FILES["file"]["tmp_name"], $targPat);
chdir('/var/www/uploads/'); chdir('/var/www/uploads/');
mkdir($jobId);
move_uploaded_file($_FILES["file"]["tmp_name"], $targPat);
chdir($jobId);
exec("ffmpeg -y -i upload.$fromExt output.$toExt"); exec("ffmpeg -y -i upload.$fromExt output.$toExt");
header("Cache-Control: public"); header("Cache-Control: public");
@ -15,7 +18,10 @@ header("Content-Disposition: attachment; filename=output.$toExt");
header("Content-Type: application/jpeg"); header("Content-Type: application/jpeg");
header("Content-Transfer-Encoding: binary"); header("Content-Transfer-Encoding: binary");
readfile("/var/www/uploads/output.$toExt"); readfile("/var/www/uploads/$jobId/output.$toExt");
chdir('/var/www/uploads/');
exec("rm -r $jobId");
?> ?>