Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-25-2007, 09:09 PM   PM User | #1
goheadtry
New Coder

 
Join Date: Sep 2007
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
goheadtry is an unknown quantity at this point
I am having trouble figuring out what is wrong with my script.

I am having trouble figuring out what is wrong with my script I can't figure it out because it does not give me an error. but the script does not work correctly
The paths I use are

/home/forbushj/ which is the root of my hosting account
/home/forbushj/public_html/ which is the root of my website
/home/forbushj/www/ which is the same as public_html
PHP Code:
<?php
if(count($_POST) <1){
//show the form
    
if(isset($_GET['error'])){
        if(
$_GET['error'] == "nofile"){
            
$if_error="Please choose a file to upload.";
        }elseif(
$_GET['error'] == "notvid"){
            
$if_error="The file you selected is not a video.";
        }elseif(
$_GET['error'] == "couldnotupload"){
            
$if_error="Your file could not be uploaded.";
        }elseif(
$_GET['error'] == "noconvert"){
            
$if_error="We're sorry, but your video could not be converted for some reason.";
        }
    }else{
        
$if_error="";
    }
    echo 
"";
}else{
//do the processing

function is_video$f ){
$result trim exec ('file -bi ' escapeshellarg $f ) ) ) ;
$TYPE explode("/"$result);
if(
$TYPE[0] == "video"){
return 
TRUE;
}
else{
return 
FALSE;
}

if(
$_FILES['ufile']['name'] == ""){
    
header("location: {$_SERVER['PHP_SELF']}?error=nofile");
    exit();
}

if(!
is_video($_FILES['ufile']['name'])){
    
header("location: {$_SERVER['PHP_SELF']}?error=notvid");
    exit();
}

if(!
move_uploaded_file($_FILES['ufile']['tmp_name'],$_SERVER['DOCUMENT_ROOT']."/uploadvidd/".$_FILES['ufile']['name'])){
    
header("location: {$_SERVER['PHP_SELF']}?error=couldnotupload");
    exit();
}

$ffmpeg '/usr/bin/ffmpeg';//location of ffmpeg binary
$bitrate '32';//bitrate for audio options are 16,32,64
$ext '.flv';//Extension of output video files
$extb '.jpg';//Extension of image
$vidsize '320x240'//video size
$imgsize '150x100';//image size for menu
$force 'flv';//Force video format to
$sstime '00:00:35';//time to take screenshot
$samprate ='22050'// Sample rate choices are as follows 11025, 22050, 44100)
//Converts uploaded video with FFmpeg binary
if(!exec('$ffmpeg -i /home/forbushj/public_html/uploadvidd/'.$vidIN.' -ar $samprate -ab $bitrate -f flv -s $vidsize /home/forbushj/public_html/vidd/'.$vidout.'.$ext.') || !exec('$ffmpeg -i /home/forbushj/public_html/vidd/'.$vidout.''.$ext.' -s $imgsize -an -ss $sstime -an -r 1 -vframes 1 -y -f image2 /home/forbushj/public_html/pic/video/'.$vidout.'.$extb.')){
    
header("location: {$_SERVER['PHP_SELF']}?error=noconvert");
    exit();
}

//write to mysql
$linkID = @mysql_connect("localhost","dsf_sdf","jdfsdf") or die("Could not connect to MySQL server");
@
mysql_select_db("forbushj_onetest") or die("Could not select database");
 
// Retrieve the posted product information.
$titlev stripslashes($_POST['vidname']);      
$descrv stripslashes($_POST['viddes']);
$srcv stripslashes($_POST['srcof']);
if(
$query=mysql_query("INSERT INTO video(`title`,`descr`,`pic`,`locat`,`src`) VALUES ('" mysql_real_escape_string($titlev) . "','" mysql_real_escape_string($descrv) . "','" mysql_real_escape_string($output) . ".jpg','" mysql_real_escape_string($output) . ".flv','" mysql_real_escape_string($srcv) . "')")){
    echo 
"Successfully uploaded and converted your file."
}
}
}
?>
<!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=utf-8" />
<title>Untitled Document</title>

</head>

<body>
<form action="http://www.technologyforever.com/zzupload.php" method="post" enctype="multipart/form-data" name="form1" id="form1">
  <label>
  <input name="vidname" type="text" id="textfield" tabindex="1" />
  </label>
  vidname
  <p>
    <label>
    <input type="text" name="srcof" id="srcof" tabindex="2" />
    </label>
  srcof</p>
  <p>
    <label>
    <textarea name="viddes" id="viddes" cols="45" rows="5" tabindex="3"></textarea>
    </label>
    viddes</p>
  <p>
    <label>
    <input name="ufile" type="file" id="ufile" tabindex="4" />
    </label>
  ufile</p>
  <p>
    <input name="button" type="submit" id="button" tabindex="5" value="Submit" />
  </p>
</form>
</body>
</html>
This script makes use of ffmpeg
here is the documentation
http://ffmpeg.mplayerhq.hu/ffmpeg-doc.html
goheadtry is offline   Reply With Quote
Old 11-25-2007, 09:30 PM   PM User | #2
aWishResigned
New Coder

 
Join Date: Nov 2007
Posts: 72
Thanks: 0
Thanked 1 Time in 1 Post
aWishResigned is an unknown quantity at this point
From the looks of it, it seems the problem is with the file uploading--or lack thereof. When you submit the form, does it come back to the same file or does it post to another file and come back when the uploading is done?
aWishResigned is offline   Reply With Quote
Old 11-25-2007, 09:48 PM   PM User | #3
goheadtry
New Coder

 
Join Date: Sep 2007
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
goheadtry is an unknown quantity at this point
Quote:
Originally Posted by aWishResigned View Post
From the looks of it, it seems the problem is with the file uploading--or lack thereof. When you submit the form, does it come back to the same file or does it post to another file and come back when the uploading is done?
The form returns to zzupload.php when finished uploading upload.html is the form part only not the script and zzupload.php is the form and the script all in one.

so the script is all in one
goheadtry is offline   Reply With Quote
Old 11-25-2007, 10:17 PM   PM User | #4
aWishResigned
New Coder

 
Join Date: Nov 2007
Posts: 72
Thanks: 0
Thanked 1 Time in 1 Post
aWishResigned is an unknown quantity at this point
Actually wait, I've got it. There were some curlys in the wrong places. Try this.

PHP Code:
<?
function is_video$f ){
    
$tmp $f['tmp_name'];
    
$file $f['name'];
    
    
$result trim exec ('file -bi ' escapeshellarg $f ) ) ) ;
    
$TYPE explode("/"$result);
    
    if(
$TYPE[0] == "video"){
        return 
TRUE;
    }else{
        return 
FALSE;
    }
}

if(
count($_POST) <1){
//show the form
    
if(isset($_GET['error'])){
        if(
$_GET['error'] == "nofile"){
            
$if_error="Please choose a file to upload.";
        }elseif(
$_GET['error'] == "notvid"){
            
$if_error="The file you selected is not a video.";
        }elseif(
$_GET['error'] == "couldnotupload"){
            
$if_error="Your file could not be uploaded.";
        }elseif(
$_GET['error'] == "noconvert"){
            
$if_error="We're sorry, but your video could not be converted for some reason.";
        }
    }else{
        
$if_error="";
    }
    echo 
"";
}else{
    
    if(
$_FILES['ufile']['name'] == ""){
    
header("location: {$_SERVER['PHP_SELF']}?error=nofile");
    exit();
    }
    
    if(!
is_video($_FILES['ufile']['name'])){
        
header("location: {$_SERVER['PHP_SELF']}?error=notvid");
        exit();
    }
    
    if(!
move_uploaded_file($_FILES['ufile']['tmp_name'],$_SERVER['DOCUMENT_ROOT']."/uploadvidd/".$_FILES['ufile']['name'])){
        
header("location: {$_SERVER['PHP_SELF']}?error=couldnotupload");
        exit();
    }
    
    
$ffmpeg '/usr/bin/ffmpeg';//location of ffmpeg binary
    
$bitrate '32';//bitrate for audio options are 16,32,64
    
$ext '.flv';//Extension of output video files
    
$extb '.jpg';//Extension of image
    
$vidsize '320x240'//video size
    
$imgsize '150x100';//image size for menu
    
$force 'flv';//Force video format to
    
$sstime '00:00:35';//time to take screenshot
    
$samprate ='22050'// Sample rate choices are as follows 11025, 22050, 44100)
    //Converts uploaded video with FFmpeg binary
    
if(!exec('$ffmpeg -i /home/forbushj/public_html/uploadvidd/'.$vidIN.' -ar $samprate -ab $bitrate -f flv -s $vidsize /home/forbushj/public_html/vidd/'.$vidout.'.$ext.') || !exec('$ffmpeg -i /home/forbushj/public_html/vidd/'.$vidout.''.$ext.' -s $imgsize -an -ss $sstime -an -r 1 -vframes 1 -y -f image2 /home/forbushj/public_html/pic/video/'.$vidout.'.$extb.')){
        
header("location: {$_SERVER['PHP_SELF']}?error=noconvert");
        exit();
    }
    
    
//write to mysql
    
$linkID = @mysql_connect("localhost","dsf_sdf","jdfsdf") or die("Could not connect to MySQL server");
    @
mysql_select_db("forbushj_onetest") or die("Could not select database");
     
    
// Retrieve the posted product information.
    
$titlev stripslashes($_POST['vidname']);      
    
$descrv stripslashes($_POST['viddes']);
    
$srcv stripslashes($_POST['srcof']);
    
    if(
$query mysql_query("INSERT INTO video(`title`,`descr`,`pic`,`locat`,`src`) VALUES ('" mysql_real_escape_string($titlev) . "','" mysql_real_escape_string($descrv) . "','" mysql_real_escape_string($output) . ".jpg','" mysql_real_escape_string($output) . ".flv','" mysql_real_escape_string($srcv) . "')")){
        echo 
"Successfully uploaded and converted your file.";
    }
}
?>

Last edited by aWishResigned; 11-25-2007 at 10:26 PM.. Reason: Finally got it right
aWishResigned is offline   Reply With Quote
Old 11-25-2007, 10:40 PM   PM User | #5
goheadtry
New Coder

 
Join Date: Sep 2007
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
goheadtry is an unknown quantity at this point
It still doesn't work

Hey IM me
This is my IM in binary for yahoo
0110011001101111011100100110001001110101011100110110100001011111011010100110111101101000011011100100 0000011110010110000101101000011011110110111100101110011000110110111101101101
or this is for hotmail
0111011101101001011011100111010001101111011011000110100101110110011001010100000001101000011011110111 01000110110101100001011010010110110000101110011000110110111101101101

If you don't know binary use this page because I don't want to place my email on this page and get spam
http://www.roubaixinteractive.com/Pl...ry_To_Text.asp
goheadtry is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:48 AM.


Advertisement
Log in to turn off these ads.