473,408 Members | 2,832 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

PHP Video Upload

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
5 16857
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
6,050 Expert 4TB
Is everything gettting inserted into the `videos` table?
Dec 9 '07 #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
6,050 Expert 4TB
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
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

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

Similar topics

8
by: poorna | last post by:
hi all i want to upload the video files to the server.. then i encode all the video files into flv files ... and then i am go to streaming ... in the mean while i create the thumbnail image...
6
by: poorna | last post by:
hi all, Can any body guide me please how to upload video files using php and how to maintain it? Is there any thing diffrent way to upload a video files? Regards, poorna
7
by: cmk128 | last post by:
Hi I have many video on my server, wmv, mpeg, avi, etc... I want to use php to catpure the first frame of the video into a png/jpeg/mpg, how to? thanks from Peter (cmk128@hotmail.com)
8
by: scriptee | last post by:
Hi guys ! I have a form, in which I want users to upload either video or image . What I want to ask is how I can set it up so, that when a user tries to upload a image when there is already a video...
3
by: pbd22 | last post by:
hi. i thought there would be volumes on this topinc on the internet, but i am having a tough time finding what i am looking for. i am trying to learn how to move a video from a cam corder or...
3
by: lukemack | last post by:
Hi, Can anyone recommend a class/script which handles video file uploads, preferably with Flash integration? I'm looking to have a video upload / library section in my cake app. I considered...
4
by: meseenu | last post by:
Hi every one, iam developing an application where i want to upload image and video files in to a oracle data base. I have used BLOB data type to store the image and video files. iam using...
4
by: scan87 | last post by:
Hello everyone...Can someone please, please help me solve a problem I am facing in my project......Basically the project is about uploading videos and viewing them.....When users upload a video (avi,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.