Salve,
ho 2 campi di un modulo .........
<form action="videoscript.php" method="post" enctype="multipart/form-data">
<select name="id" id="id" >
<option value="3">prova video</option>
</select>
<p align="center">Inserisci il video
<input name="audio" type="file" />
<input type="submit" name="button" id="button" value="Invia" />
</p>
</form>
........................... ora vorrei far sì che quando invio il modulo lo script videoscript.php lavori in background così da non dover aspettare la fine del processo di trasformazione di ffmpeg e quindi poter subito chiudere il browser
..... questo e il video script:
videoscript.php :
ini_set( "max_execution_time", "3600" ); // sets the maximum execution time of this script to 1 hour.
$fileName = $_FILES['audio']['name']; // get client side file name
if( $fileName ) {
// Check File Type
$fileNameParts = explode( ".", $fileName ); // seperate the name from the ext
$fileExtension = end( $fileNameParts ); // part behind last dot
$fileExtension = strtolower( $fileExtension ); // reduce to lower case
if( !$fileExtension == "mpg" && !$fileExtension == "avi" && !$fileExtension == "mpeg" && !$fileExtension == "wmv" && !$fileExtension == "rm" && !$fileExtension == "dat" ) {
die( "Invalid Video Format." );
}
// Check File Size
$fileSize = $_FILES['audio']['size']; // size of uploaded file
if( $fileSize == 0 ) {
die( "Sorry. The upload of $fileName has failed. The file size is 0." );
} else if( $fileSize > 1024000000 ) { //900 MB
die( "Sorry. The file $fileName is larger than 900MB. Advice: reduce the file quality and upload again." );
} else {
$uploadDir = '/var/www/vhosts/miosito.it/httpdocs/new/video2/uploaded/'; // Where the temp file will go
$uploadFile = str_replace( " ", "", $uploadDir . $_FILES['audio']['name'] ); // Get rid of spaces in the filename
$finalDir = '/var/www/vhosts/miosito.it/httpdocs/new/video2/converted/'; // Where the final file will go
$finalFile = str_replace( " ", "", $finalDir . $fileNameParts[0] . ".flv" ); // Get rid of spaces in the filename
if ( !move_uploaded_file( $_FILES['audio']['tmp_name'], $uploadFile ) ) {
echo "Possible file upload attack! Here's some debugging info:\n";
echo( $_FILES );
}
$encode_cmd = "/usr/bin/ffmpeg -i $uploadFile -acodec mp3 -ar 22050 -ab 32 -f flv -author \"Clip Author\" -copyright \"Clip Copyright\" $finalFile";
exec( $encode_cmd );
echo $finalFile;
chmod($finalFile, 0644 );
}
}
lo script funziona bene ma come farlo lavorare in background senza dover attendere l'esecuzione dello script?