homepage Welcome to WebmasterWorld Guest from 23.23.57.182
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
upload video file using PHP-Mysql
upload small videofiles in php and store them in db using mysql
vanik

5+ Year Member



 
Msg#: 3670143 posted 5:17 am on Jun 9, 2008 (gmt 0)

Hi,
I am using php4.Please tell me how we can upload small video files using php.

 

deMorte

5+ Year Member



 
Msg#: 3670143 posted 8:47 am on Jun 9, 2008 (gmt 0)

You can find a tutorial on the subject of uploading content by googling: tizag.com upload

The tutorial points this as well but remember that the script presented there is not very safe and you should do some checking on the files to be uploaded.

vanik

5+ Year Member



 
Msg#: 3670143 posted 10:57 am on Jun 9, 2008 (gmt 0)

Hi,

I went through the google:tizag.com.But i didnt found the files for uploading the videos.Can u provide me some more information.I successfully uploaded the images but the videos will not be uploaded.

barns101

5+ Year Member



 
Msg#: 3670143 posted 12:36 pm on Jun 9, 2008 (gmt 0)

I successfully uploaded the images but the videos will not be uploaded.

I'd have thought that the only difference between uploading images and videos would be the file size. I would firstly check whether your server's maximum file upload size is the problem.

vanik

5+ Year Member



 
Msg#: 3670143 posted 5:31 am on Jun 10, 2008 (gmt 0)

Hi,
I successfully uploaded the .txt file but here is the problem is the extensions.So,plz tell me how can i change it as video extension like mpeg.Here is my complete code.

<?

$num_of_uploads=1;
$file_types_array=array("txt");
$max_file_size=1048576;
$upload_dir="";
if(!is_numeric($max_file_size)){
$max_file_size = 1048576;
}
if(!isset($_POST["submitted"])){
$upload1="upload1.php";
$form = "<form action='".$upload1."' method='post' enctype='multipart/form-data'>Upload files:<br /><input type='hidden' name='submitted' value='TRUE' id='".time()."'><input type='hidden' name='MAX_FILE_SIZE' value='".$max_file_size."'>";
for($x=0;$x<$num_of_uploads;$x++){
$form .= "<input type='file' name='file[]'><font color='red'>*</font><br />";
}
$form .= "<input type='submit' value='Upload'><br /><font color='red'>*</font>Maximum file length (minus extension) is 15 characters. Anything over that will be cut to only 15 characters. Valid file type(s): ";
for($x=0;$x<count($file_types_array);$x++){
if($x<count($file_types_array)-1){
$form .= $file_types_array[$x].", ";
}else{
$form .= $file_types_array[$x].".";
}
}
$form .= "</form>";
echo($form);
}else{
foreach($_FILES["file"]["error"] as $key => $value){
if($_FILES["file"]["name"][$key]!=""){
if($value==UPLOAD_ERR_OK){
$origfilename = $_FILES["file"]["name"][$key];
$filename = explode(".", $_FILES["file"]["name"][$key]);
$filenameext = $filename[count($filename)-1];
unset($filename[count($filename)-1]);
$filename = implode(".", $filename);
$filename = substr($filename, 0, 15).".".$filenameext;
$file_ext_allow = FALSE;
for($x=0;$x<count($file_types_array);$x++){
if($filenameext==$file_types_array[$x]){
$file_ext_allow = TRUE;
}
}
if($file_ext_allow){
if($_FILES["file"]["size"][$key]<$max_file_size){
if(move_uploaded_file($_FILES["file"]["tmp_name"][$key], $upload_dir.$filename)){
echo("File uploaded successfully. - <a href='".$upload_dir.$filename."' target='_blank'>".$filename."</a><br />");
}else{
echo($origfilename." was not successfully uploaded<br />");
}
}else{
echo($origfilename." was too big, not uploaded<br />");
}
}else{
echo($origfilename." had an invalid file extension, not uploaded<br />");
}
}else{
echo($origfilename." was not successfully uploaded<br />");
}
}
}
}

?>


jatar_k

WebmasterWorld Administrator jatar_k us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 3670143 posted 11:55 am on Jun 10, 2008 (gmt 0)

you would probably need to add other filetypes to this line

$file_types_array=array("txt");

barns101

5+ Year Member



 
Msg#: 3670143 posted 11:56 am on Jun 10, 2008 (gmt 0)

EDIT: Beaten to it!

Only had a quick look, but I think you just need to add the MPEG file extension to your file types array:

$file_types_array=array("txt", "mpg");

penders

WebmasterWorld Senior Member penders us a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month



 
Msg#: 3670143 posted 12:53 pm on Jun 10, 2008 (gmt 0)

upload small videofiles in php and store them in db using mysql

Just to note... you probably don't want to actually store the video in the db. It would be more likely to store just the filename in the db and the video file on the filesystem - which is probably what you are doing.

jatar_k

WebmasterWorld Administrator jatar_k us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 3670143 posted 1:08 pm on Jun 10, 2008 (gmt 0)

good point penders

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved