jameschambers Posted June 22, 2006 Share Posted June 22, 2006 I'm trying to write a script that will rename a video uploaded into a form then move it into a folder, but it won't recognise the file type. I have been uploading a file with a .mpg extenstion to test it but all i am getting is [b]'invalid video format: video/x-mpeg'[/b] I looked up mpeg/mpe/mpg file formats and as far as i can tell it should be ok. Here is the relevant code:[i]from video.php[/i]<form action="video_submit.php" method="post" enctype="multipart/form-data"><input type="file" name="video" class="upload" size="40"><input type="submit" value="Update Project" class="updatebutton"></form>[i]from video_submit.php[/i]if ( (isset($_FILES['video']['name']) && is_uploaded_file($_FILES['video']['tmp_name']))) { if (!isset($_REQUEST['story']) || $_REQUEST['story']=='') { $story = mysqli_insert_id($handle); } $type = basename($_FILES['video']['type']); switch ($type) { case 'mpg': case 'mpeg': case 'mpe': $filename = "video/$story.mpg"; move_uploaded_file($_FILES['video']['tmp_name'], '../'.$filename); $query = "update stories set video = '$filename' where id = $story"; $result = $handle->query($query); break; case 'avi': case 'vfw': case 'avx': $filename = "video/$story.avi"; move_uploaded_file($_FILES['video']['tmp_name'], '../'.$filename); $query = "update stories set picture = '$filename' where id = $story"; $result = $handle->query($query); break; default: echo 'Invalid video format: '. $_FILES['video']['type']; } }Any help gratefully received. Quote Link to comment https://forums.phpfreaks.com/topic/12623-file-type-not-recognised/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.