Jump to content


Photo

file type not recognised


  • Please log in to reply
No replies to this topic

#1 jameschambers

jameschambers
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 22 June 2006 - 10:11 AM

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
'invalid video format: video/x-mpeg'
I looked up mpeg/mpe/mpg file formats and as far as i can tell it should be ok.

Here is the relevant code:

from video.php


<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>

from video_submit.php

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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users