Need help with code i am trying to acheive upload of videos but when they are uploaded the file names
need to be changed to have hyphens in replace of white space and still keep the exstensions.
its proving difficult because once uploaded ffmpeg needs to read the output as the new file name so it can be
placed into the database and echo'ed out later :)
Ive searched about and tried for hours now i just need a little guidance as my brain is turning to mush at the min.
<?php
if ($_POST) {
$folder = "../videos/";
$redirect = "http://www.url.com/admin/imitv.php?success";
$title = $_POST['title'];
$description = $_POST['description'];
$video_cat_id = $_POST['video_cat_id'];
move_uploaded_file($_FILES["imagefile"]["tmp_name"], "$folder" . $_FILES["imagefile"]["name"]);
$imagefile = $_FILES['imagefile']['name'];
//VIDEO
move_uploaded_file($_FILES["file"]["tmp_name"], "$folder" . $_FILES["file"]["name"]);
$input = ("$folder" . $_FILES['file']['name']);
$new_input = pathinfo("$folder" . $_FILES['file']['name']);
$new_input=preg_replace('/[^A-Za-z0-9-]+/', '-', $new_input);
$new_video = trim($new_input);
$output = ("$folder" .$new_video."NEW.mp4");
//rename('../videos/'.$_FILES['file']['name'], '../videos/'.$new_video.'NEW.mp4');
echo "Converting $input to $output<br />";
//$command = "ffmpeg -i $video_name -ab 106kb -b 2109kb -s hd720 -ar 44100 -r 29.96 $output";
$command = "ffmpeg -i $input $output";
echo "$command<br />";
echo shell_exec( $command );
echo "Converted<br />";
$con = mysql_connect("localhost","user","pass");
if (!$con) {die('Could not connect: ' . mysql_error());}
mysql_select_db("database", $con);
$sql="INSERT INTO table VALUES ('null', '$title', '$description', '$output', '$imagefile', '$video_cat_id')";
if (!mysql_query($sql,$con)){die('Error: ' . mysql_error());}
mysql_close($con);
header('Location: '.$redirect); die;
}
?>