Need some PHP assistance...
Am in middle of sorting a website... need to be able to upload video via PHP. Server (FreeBSD6.2) is all setup for encoding & playback and that bit's done n' dusted and verified working (Lame / ffMpeg / Ruby / FLVTool2 / SWFObject / JWPlayer). Have previously been doing conversions as and when required on WinXP workstation then ftping them up - I have scripts scanning folders to build playlists on-the-fly etc, but am now at the point where I just wanna be able to tell folks to upload their video clips thru the site rather than coming to me...
Here's as far as I've got...
The form:
Code:
<form enctype="multipart/form-data" action="processupload.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="104857600" />
Send this file: <input name="userfile" type="file" />
<input type="submit" value="Send File" />
</form>
processupload.php:
Code:
<?php
error_reporting(E_ALL);
ini_set("session.gc_maxlifetime","10800");
$uploaddir = '/INCOMINGPATH/';
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
echo '<pre>';
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
echo "File is valid, and was successfully uploaded.\n";
} else {
echo "File upload was unsuccesful.\n";
}
if (chmod($uploadfile, 0744)) {
echo "CHMOD was succesful. \n";
} else {
echo "CHMOD failed. File is executable. \n";
}
$last_line = system('ffmpeg -i '.$uploadfile.' '.$uploadfile.'.flv', $retval);
$last_line = system('cat '.$uploadfile.'.flv | flvtool2 -U stdin '.$uploadfile.'.flv', $retval);
exec('rm '.$uploadfile.'');
echo 'Here is some more debugging info:';
print_r($_FILES);
print "</pre>";
?>
Thus far, works peachy... it accepts uploaded file and automatically converts to FLV using FFMPEG then injects MetaData using FLVTOOL2... but I need to tweak it a bit more and it goes beyond my (very basic) skills... am a designer not a programmer.
1 - I need it to only allow upload of video formats (avi, mpg, mov)...
2 - the filename of the flv file produced is currently originalfilename.originalextension.flv - I need to lose the original extension...
Can anyone point me in the right direction?