Jump to content

uploading video


wompas.dub

Recommended Posts

I'm trying to make a script to upload .mov files
this is the code I have - really the only thing I can't figure out is instead of image/jpeg or gif etc. what do I put exactly for video files? specifically .movs
[code]

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>File Upload script</title>
</head>

<body>
<h1>Upload...</h1>
<form name="form1" method="post" action="" enctype="multipart/form-data">
<input type="file" name="videofile">
<br>
<input type="submit" name="Submit" value="Submit">

<?
if(isset( $Submit ))
{
//If the Submitbutton was pressed do:
$vid_name = $_FILES['videofile']['name'];

mysql_select_db('sec2nun', $db);

$sql = "INSERT INTO `site_tbl` ( `u_ID` , `page_title` , `page_img` , `page_vid` , `page_content` , `featured_id` )
VALUES (
NULL , '', '', 'vid_name', '', '0'
) ";
if ($_FILES['videofile']['type'] == "video/mov"){

copy ($_FILES['videofile']['tmp_name'], "uploads/".$_FILES['videofile']['name'])
    or die ("Could not copy");
$result = mysql_query($sql, $db);
if(!$result){
echo "failed to insert image information into mySQL database, reason: ";
echo mysql_error();
die();
}
else{
echo "image information successfully added to mySQL database...<br/> ";
    }
echo "";
        echo "<br/>";
echo "Name: ".$_FILES['videofile']['name']."";
        echo "<br/>";
echo "Size: ".$_FILES['videofile']['size']."";
        echo "<br/>";
echo "Type: ".$_FILES['videofile']['type']."";
        echo "<br/>";
echo "Copy Done....<br/><br/>";
        echo "image preview:<br/><EMBED SRC=\"uploads/$vid_name\" height=\"365\" width=\"345\" autostart=\"true\" loop=\"false\"></EMBED>";
}

        else {
            echo "<br><br>";
            echo "Could Not Copy, Wrong Filetype (".$_FILES['imagefile']['name'].")<br>";
        }
}

?> </form>




</body>
</html>

</body>
</html>

[/code]

any help would be much appreciated. thanks
Link to comment
Share on other sites

Well I already wrote the image upload, I just need to make a way to upload video files instead of image files. I've honestly never attempted this before, Specifically the section that says :
[code]
if ($_FILES['videofile']['type'] == "video/mov"){

[/code]

When I attempt to upload a .mov file it takes forever and finally tells me its an invalid file type.
Link to comment
Share on other sites

heres my full code becouse your asking nicly .

i use to make money with this.

look at the 200000000000000000000000 lol

good luck mate.

[code]
<?php session_start();



$db=mysql_connect("localhost" ,"xxx","xxx");

mysql_select_db("promotor",$db);


$query="select * from members_video_uploads where name='$name' and id='$id'";

$result=mysql_query($query);

while($row=mysql_fetch_assoc($result)) {

if($row["userfile_name"]=1) {

echo "<b>Sorry you have a video already</b><br><br><a href='members_video_update_form.php'>Update video</a><br><br>";
exit;
}
}


$date_sent=date("d-m-y");

if(!$userfile=="none") {
echo"No file specified<br><br><br><a href='members_upload_video_form.php'>please try agin</a><br><br>";
exit;
}


$uploaddir ="members_video/";
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);

$size=$_FILES['userfile']['size'];



$type=($_FILES['userfile']['type']=="video/mpeg");

if($size <= 842112) {

if($type) {



if(move_uploaded_file($_FILES['userfile']['tmp_name'],$uploadfile)) {


$userfile_name=addslashes($userfile_name);

$query="insert into members_video_uploads values('$id','$name','$date_sent','$userfile_name')";

$result=mysql_query($query);



echo "File uploaded";

}else{
echo"no file uploaded <br><br><br><a href='members_upload_video_form.php'>please try agin</a><br><br>";
}

}else{
echo"sorry your file type is wrong .mpg Only<br><br><br><a href='members_upload_video_form.php'>please try agin</a><br><br>";
exit;
}

}else{
echo"Wrong size 842112 bytes approx 3 min only <br><br><br><a href='members_upload_video_form.php'>please try agin</a><br><br>";
exit;
}
?>
[/code]


update

[code]

<?php session_start();

$db=mysql_connect("localhost" ,"xxx","xxx");
mysql_select_db("promotor",$db);
$query="select * from members_video_uploads where name='$name' and id='$id'";
$result=mysql_query($query);
while($row=mysql_fetch_assoc($result)) {
?>

<html>
<head>
<body>
<h1>Please update profile video!</h1><br>

<br><br>Current video name:<br><font color="red"><b><?phpecho $row["userfile_name"];}?></b></font>

<form enctype="multipart/form-data" action="members_update_video_result.php" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="20000000">
<br>
please choose a diffrent video
<br>
<input type="file"  name="userfile">
<br>
<input type="submit" value="send">
<br>
</form>
</html>
</body>

[/code]

update_result
[code]
<?php session_start();

$db=mysql_connect("localhost" ,"xxx","xxx");

mysql_select_db("promotor",$db);


$date_sent=date("d-m-y");

if(!$userfile=="none") {

echo"No file specified<br><br>
<a href='members_video_update_form.php'>Please try agin</a>";
exit;
}

$uploaddir ="members_video/";
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);

$size=$_FILES['userfile']['size'];


$type=($_FILES['userfile']['type']=="video/mpeg");

if($size <= 90000000000000000000) {

if($type) {

if(move_uploaded_file($_FILES['userfile']['tmp_name'],$uploadfile)) {


$userfile_name=addslashes($userfile_name);

$db=mysql_connect("localhost" ,"root","admin");
mysql_select_db("promotor",$db);
$query="update members_video_uploads set userfile_name='$userfile_name' where id='$id'";
$result=mysql_query($query);



echo "File uploaded";

}else{
echo"no file uploaded <br><br><br><a href='members_update_video_form.php'>please try agin</a><br><br>";
}

}else{
echo"Sorry your file type is wrong .mpeg Only<br><br><br><a href='members_video_update_form.php'>please try agin</a><br><br>";
exit;
}

}else{
echo"sorry your file size is wrong 842112 bytes approx 3 min Only<br><br><br><a href='members_update_video_form.php'>please try agin</a><br><br>";
exit;
}
?>
[/code]


form.
[code]
<html>
<head>
<body>
<h1>please upload a video!</h1><br>

<form enctype="multipart/form-data" action="members_upload_video_result.php" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="2000000000000000000">
<br>
please choose a video
<br>
<input type="file" name="userfile">
<br>
<input type="submit" value="send">
<br>

</form>
</html>
</body>

[/code]
Link to comment
Share on other sites

Update:
I figured out what you have to put for uploading .mov files:

video/quicktime
video/mpeg for mpegs

All I did to make mine work is bypass the conditional statement that tells it to display errors if its of the wrong extension. What I got at the end of everything being displayed was:
Name: 22n.mov
Size: 4122342
Type: video/quicktime
File Uploaded:....

I got the type of it and put video/quicktime instead of video/mpeg as I didn't know what exactly to put. Anyway, it works and your script was definetly a great help to get mine running. Is there anything I can do to speed the upload speed though? On average its taking 3 minutes.

Thanks for the help it was greatly appreciated.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.