Jump to content

Archived

This topic is now archived and is closed to further replies.

jameschambers

file type not recognised

Recommended Posts

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.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.