Jump to content


Photo

uploading video


  • Please log in to reply
7 replies to this topic

#1 wompas.dub

wompas.dub
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 28 August 2006 - 01:26 AM

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

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


any help would be much appreciated. thanks


#2 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 28 August 2006 - 01:29 AM

what do you mean you want to only do what? or get what? please tell me.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#3 wompas.dub

wompas.dub
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 28 August 2006 - 01:33 AM

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 :
if ($_FILES['videofile']['type'] == "video/mov"){ 


When I attempt to upload a .mov file it takes forever and finally tells me its an invalid file type.

#4 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 28 August 2006 - 01:45 AM

heres my full code becouse your asking nicly .

i use to make money with this.

look at the 200000000000000000000000 lol

good luck mate.

<?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;
}
?>


update


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


update_result
<?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;
}
?>


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


Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#5 wompas.dub

wompas.dub
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 28 August 2006 - 01:47 AM

Nice, Thanks man.
I will try using video/mpeg and try uploading a .mov if not I guess it will only upload mpeg :P haha

#6 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 28 August 2006 - 01:58 AM

ok mate you got it all above ok good luck all the best.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#7 wompas.dub

wompas.dub
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 29 August 2006 - 02:04 AM

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.

#8 wompas.dub

wompas.dub
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 30 August 2006 - 05:02 AM

Can someone tell me why it takes 3-5 minutes for a video upload? What can I do to speed this up, is there any way possible? filesize is around 5 megs





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users