By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,084 Members | 1,956 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,084 IT Pros & Developers. It's quick & easy.

PHP Video Upload

P: 3
I'm having trouble getting my PHP code to upload videos. I have a page that uploads Images, which uploads to a table called Photos and everything works fine. I tried modifying that code to upload videos to a table called Videos, but I don't see the files in the folder that I assigned it to. There are no errors when I upload the file, and the file size and type is within the conditions that I set. Any suggestions, this is my code:

function valid($img_ext){
$ext = array(
//ext types
'video/wmv' => 'wmv',
'video/mov' => 'mov',
);

if(array_key_exists($img_ext, $ext)){
return true;
break;
}
else
return false;
}

if(valid($_FILES['uploadvideo']['type']) == true){

if ($_FILES["uploadvideo"]["size"] < 10240000){
if ($_FILES["uploadvideo"]["error"] == false){
//Uploads and stores in temporary location for further verification
$_FILES["uploadvideo"]["$name"];
$_FILES["uploadvideo"]["tmp_name"];

if (file_exists("Videos/Orig/".$_FILES["uploadvideo"]["name"])){
echo $_FILES["uploadvideo"]["name"], " already exists. ";
}
else{
move_uploaded_file($_FILES["uploadvideo"]["tmp_name"], "Videos/Orig/" . $_FILES["uploadvideo"]["name"]);
//calls the thumbnail maker function
//imageThmb();
$src = $_FILES["uploadvideo"]["name"];
$thumb = "thmb_".basename($_FILES['uploadvideo']['name']);
mysql_query("INSERT INTO `ttakara`.`Videos` (`ID` ,`name`, `description` ,`Link_Orig` ,`Link_Thumb` ,`approve`, `User_ID` ) VALUES ('' , '$name', '$description', '$src', '$thumb', 0, '');");
}
}
//Prints an error if image failed to upload
else{
echo "Error: ".$_FILES["uploadvideo"]["error"]."<br />";
}
}
else{
//alerts user that the image is too large
echo "<script>alert('The image you are trying to upload is too large.')</script>";
}
}
Dec 8 '07 #1
Share this Question
Share on Google+
5 Replies


P: 3
I'm having trouble getting my PHP code to upload videos. I have a page that uploads Images, which uploads to a table called Photos and everything works fine. I tried modifying that code to upload videos to a table called Videos, but I don't see the files in the folder that I assigned it to. There are no errors when I upload the file, and the file size and type is within the conditions that I set. Any suggestions, this is my code:

function valid($img_ext){
$ext = array(
//ext types
'video/wmv' => 'wmv',
'video/mov' => 'mov',
);

if(array_key_exists($img_ext, $ext)){
return true;
break;
}
else
return false;
}

if(valid($_FILES['uploadvideo']['type']) == true){

if ($_FILES["uploadvideo"]["size"] < 10240000){
if ($_FILES["uploadvideo"]["error"] == false){
//Uploads and stores in temporary location for further verification
$_FILES["uploadvideo"]["$name"];
$_FILES["uploadvideo"]["tmp_name"];

if (file_exists("Videos/Orig/".$_FILES["uploadvideo"]["name"])){
echo $_FILES["uploadvideo"]["name"], " already exists. ";
}
else{
move_uploaded_file($_FILES["uploadvideo"]["tmp_name"], "Videos/Orig/" . $_FILES["uploadvideo"]["name"]);
//calls the thumbnail maker function
//imageThmb();
$src = $_FILES["uploadvideo"]["name"];
$thumb = "thmb_".basename($_FILES['uploadvideo']['name']);
mysql_query("INSERT INTO `ttakara`.`Videos` (`ID` ,`name`, `description` ,`Link_Orig` ,`Link_Thumb` ,`approve`, `User_ID` ) VALUES ('' , '$name', '$description', '$src', '$thumb', 0, '');");
}
}
//Prints an error if image failed to upload
else{
echo "Error: ".$_FILES["uploadvideo"]["error"]."<br />";
}
}
else{
//alerts user that the image is too large
echo "<script>alert('The image you are trying to upload is too large.')</script>";
}
}
Can anyone help me please, really urgent!
Dec 9 '07 #2

Markus
Expert 5K+
P: 6,050
Is everything gettting inserted into the `videos` table?
Dec 9 '07 #3

P: 3
no records are actually being inserted into the table, but I know that code is right because as soon as I change the type from video to image, everything works for images.
Dec 9 '07 #4

Markus
Expert 5K+
P: 6,050
Are videos passed through the $_FILES array?

I'll have a check!

Yes they are - silly me.

Hmmm, have you tried increasing the

$_FILES["uploadvideo"]["size"] < 10240000){

?
Dec 9 '07 #5

P: n/a
Are videos passed through the $_FILES array?

I'll have a check!

Yes they are - silly me.

Hmmm, have you tried increasing the

$_FILES["uploadvideo"]["size"] < 10240000){
Oct 5 '10 #6

Post your reply

Sign in to post your reply or Sign up for a free account.