Image file doesn't appear in the db table

It might be helpful if you posted ALL your form processing. You said you are able to add other posted inputs, i.e. title, description, tags etc into the videos table. This is the First query I was referring to. I’ve assumed this was done before trying to add the thumbnail.

(Sorry I just edited the code in the previous post, it had duplicates)
I’m not sure what more code you’re looking for, I’ve posted the html Form and the code specific to the Image upload. The Upload Form has this:

<form enctype="multipart/form-data" action="uploader.php" method="POST">

Here is the uploader.php code:

<?php

include_once ('classes/config.php');
include_once ('classes/sessions.php');
include 'uploader_conlib.php';

$config['notification_error'] = $lang_error;

$page_title = $lang_upload_video;


if ($_SESSION['user_id'] == "") {
header("Location: " . "$base_url/login.php");
die();
}

$load_javascript	= 1;
$ahah			= 1;
$thickbox = 1;

///////////////////////////////////////////////////////////////////////////////////////
// ADDED SPAMMER UPLOAD TRACKING LOGING
//

$member_uploading		= $_SESSION['user_name'];
$tracking_log_file	= 'logs/uploader_log.txt';
$admin_email		= $config['admin_notify_email'];
$user_ip			= mysql_escape_string($_SERVER['REMOTE_ADDR']);
$referer			= mysql_real_escape_string($_SERVER['HTTP_REFERER']);

if ( $referer == '' ) die_spammer_alerts();
if ( !ereg ($_SERVER['SERVER_NAME'], $referer) ) die_spammer_alerts();

///////////////////////////////////////////////////////////////////////////////////////

//echo $debugmodex;

//get channel data, create "select" form fields to load into form
$sql			= "SELECT channel_id, channel_name FROM channels";
$result1 		= @mysql_query($sql);
$count_cats 	= @mysql_num_rows($result1);
$fields_all 	= '';
$sub_fields_all	= '';
$show_fields	= '';

$fields_all .= '<option value="99999">Select One</option>';

while ($result = @mysql_fetch_array($result1)) {
	$fields_all .= '<option     value="'.$result['channel_id'].'">'.$result['channel_name'].'</option>';
}

$sub_cat_choice = (int) mysql_real_escape_string( $_GET['sub_cat'] );

if ( $sub_cat_choice ) {

if ( $sub_cat_choice == '99999' ) {

	$sub_fields_all  .= '<select class="image_form" style="width:160px;" size="1"     name="sub_cat">';
	$sub_fields_all  .= '<option     value="99999">'.$lang_no_sub_categories.'</option>';
	$sub_fields_all .= '</select>&nbsp;('.$lang_select.')';
	echo $sub_fields_all;
	die();

} else {

	$sql2			= "SELECT * from sub_channels WHERE parent_channel_id =     $sub_cat_choice";
  	$query		= @mysql_query($sql2);
	$sub_fields_all  .= '<select class="image_form" style="width:160px;" size="1"  name="sub_cat">';

  	while ($result2 = @mysql_fetch_array($query)) {
			$count_subs		= @mysql_num_rows($query);
			$sub_fields_all  .= '<option     value="'.$result2['sub_channel_id'].'">'.$result2['sub_channel_name'].'</option>';
 		}

 		if ( $count_subs == '' ) {
 			$sub_fields_all  .= '<option value="99999">'.$lang_no_sub_categories.'</option>';
	}

 		$sub_fields_all .= '</select>&nbsp;('.$lang_select.')';

 		echo $sub_fields_all;
     	die();
}
}


// grab values from form if any
$form_submitted		= $_POST['form_submitted'];
$title 			= $_POST['title'];
$description 		= $_POST['description'];
$tags 			= $_POST['tags'];
$thumbnail    = $_POST['thumbnail'];
$new    = $_POST['new'];
$location_recorded	= $_POST['location_recorded'];
$allow_comments 		= $_POST['allow_comments'];
$allow_embedding 		= $_POST['allow_embedding'];
$public_private 		= $_POST['public_private'];
$channel 			= $_POST['channel'];
$sub_cat			= $_POST['sub_cat'];
$procede 			= true;

///////////////////////////////////////
/////////////////////////////////////////
if ($form_submitted == 'yes') {
$allowedExts = array("gif", "jpeg", "jpg", "pdf", "png");
$temp = explode(".", $_FILES["file"]["name"]);
$extension = strtolower( end($temp) );
if (!in_array($extension,$allowedExts))
{
echo ("Error - Invalid File Name");
}
$length = 20;
$thumbnail = $_SESSION['user_id'].$_FILES["file"]["name"];
move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $thumbnail);
$sql = "INSERT INTO videos (thumbnail) VALUES( '$thumbnail' )";

mysql_query($sql);
$file_location = '<a href="http://www......com/upload/' . $thumbnail . '">' . $thumbnail .  '</a>';
}
///////////////////////////////////////

/////////////////////////////////////////

$row = mysql_query(“SELECT channel_name FROM channels WHERE channel_id = ‘$channel’”);

while( $result = mysql_fetch_assoc($row) ) $channel_name = $result['channel_name'];

// validate form
if ($form_submitted == 'yes') {

if ($_SESSION['user_id'] == '') die();
$post_vid_upload_token	= mysql_real_escape_string( $_POST['vid_upload_token']    );

if ( $post_vid_upload_token != $_SESSION['vid_upload_token'] ) die();

foreach ($_POST as $key => $value) {
  	if ($key == 'title' || $key == 'description' || $key == 'tags' || $key == '$channel' || $key  == 'new') {
        	if (!isset($value) || ($value == '')) {
            		$display_key	= @str_replace('_', ' ', $key);
            		$error_message	= $config['notification_error'];
            		$blk_notification = 1;
            		$error_message 	= $error_message . " - " . $display_key . "  -     $lang_required ";
            		$procede 		= false;
        	}
    	}
	}

	if ( $channel == '99999' ) {

		$error_message	= $config['notification_error'];
 		$blk_notification = 1;
 		$error_message 	= $error_message . " - $lang_select_channel";
		$procede 		= false;
	}
} else {

$procede = false;
}

// display page with form error
if ($procede == false && $form_submitted == 'yes') {
$template 		= "themes/$user_theme/templates/main_1.htm";
	$inner_template1 	=  "themes/$user_theme/templates/inner_upload_video_form.htm";
	$TBS 			= new clsTinyButStrong;
	$TBS->NoErr 	= true;
	$TBS->LoadTemplate("$template");
	$TBS->Render 	= TBS_OUTPUT;
	$TBS->Show();
@mysql_close();
	die();
}

// disply clean page
if (!isset($form_submitted) || ($form_submitted == "")) {
$template 		= "themes/$user_theme/templates/main_1.htm";
	$inner_template1 	=   "themes/$user_theme/templates/inner_upload_video_form.htm";
	$TBS 			= new clsTinyButStrong;
	$TBS->NoErr 	= true;
	$TBS->LoadTemplate("$template");
	$TBS->Render 	= TBS_OUTPUT;
	$TBS->Show();
	@mysql_close();
	die();
}

if ($procede == true && $form_submitted == 'yes') {
if ($_SESSION['user_id'] == "") die();

//=================================START OF   UPLOAD=================================
$THIS_VERSION = '2.0';
if (isset($_GET['cmd']) && $_GET['cmd'] == 'about') {
    kak("<u><b>UBER UPLOADER FILE UPLOAD</b></u><br>UBER UPLOADER  VERSION =  <b>" .
        $UBER_VERSION . "</b><br>UU_FILE_UPLOAD = <b>" . $THIS_VERSION . " <b><br>\n");
}
$tmp_sid = md5(uniqid(mt_rand(), true));
///////////////////////////////////////////////////////////////////////
// This is where you might set your config file eg.                  //
// if($_SESSION['user'] == "tom"){ $config_file = 'uu_tom_config'; } //
///////////////////////////////////////////////////////////////////////
$config_file = $default_config_file;
$path_to_upload_script .= '?tmp_sid=' . $tmp_sid;
$path_to_ini_status_script .= '?tmp_sid=' . $tmp_sid;

if ($MULTI_CONFIGS_ENABLED) {
    $path_to_upload_script .= "&config_file=$config_file";
    $path_to_ini_status_script .= "&config_file=$config_file";
}

//allow form to be refilled on error
foreach($_POST as $key=>$value) {
     $$key = $value;
}

$template = "themes/$user_theme/templates/main_1.htm";
$inner_template1 = "themes/$user_theme/templates/inner_upload_video.htm";
$TBS = new clsTinyButStrong;
$TBS->NoErr = true;// no more error message displayed.
$TBS->LoadTemplate("$template");
$TBS->Render = TBS_OUTPUT;
$TBS->Show();

@mysql_close();
die();
    //===============================================================E    ND OF  UPLOADER======================================================== ========
}

function die_spammer_alerts() {

global $member_uploading, $user_ip, $admin_email, $site_name;

$subject	= 'Possible Video Spamming !!';

$message	= "The following member uploaded a possible spam video: => " .   $member_uploading . "\n\n" . "The IP used: " . $user_ip . "\n";

$to		= $admin_email;
  $from 	= $site_name;

  mail($to, $subject, $message, "From: $from");

  // if config auto ban spammer is true - enter user name and ip to ban table
  /*
  include_once ('classes/config.php');
  $sql		= "DELETE FROM videos WHERE video_id = '$raw_video'";
  $query	= @mysql_query($sql);
  */

  write_log($message);
}

function write_log($message) {
global $tracking_log_file;

if (@file_exists($tracking_log_file)) {
		$fo = @fopen($tracking_log_file, 'a');
    	@fwrite($fo, $message);
    	@fclose($fo);

	} else {
  	$fo = @fopen($tracking_log_file, 'w');
    	@fwrite($fo, $message);
    	@fclose($fo);
	}
exit();
}
?>

Any additional help is appreciated.

From POST #12[quote=“ChrisjChrisj, post:12, topic:104584”]
because what you’re suggesting is beyond my knowledge of how to do that, or why to do that, and it seems that the other form inputs are already appearing successfully.
[/quote]Appearing where? Where or when are you processing “the other form inputs”?
You’ve asked about putting the thumbnail in the same table row as “the other form inputs”.

I belive its in uploader_finished.php:

 <?php

    include_once ('classes/config.php');
    include_once ('classes/sessions.php');
    include_once ('classes/login_check.php');

    //upload include
    require 'uploader_conlib.php';

    $config_video_title_length	= $config['video_title_length'];

    //===================================START OF UPLOADER    (ubber)================================

    $THIS_VERSION = "4.0";

    /////////////////////////////////////////////////////////////////
    // The following possible query string formats are assumed
    //
   // 1. ?upload_dir=tmp_sid&path_to_upload_dir
    // 2. ?cmd=about
    /////////////////////////////////////////////////////////////////

    // Hard-code the 'temp_dir' value here instead of passing it in the address bar.

    $temp_dir	= $_REQUEST['temp_dir']; 
    $_POST_DATA = getPostData($temp_dir, $_REQUEST['tmp_sid']);

    $title 			= $_POST_DATA['title'];
    $description 		= $_POST_DATA['description'];
    $tags 			= $_POST_DATA['tags'];

    $location_recorded	= $_POST_DATA['location_recorded'];
    $thumbnail	        = $_POST_DATA['thumbnail'];
    $allow_comments 		= $_POST_DATA['allow_comments'];
    $allow_embedding 		= $_POST_DATA['allow_embedding'];
    $public_private 		= $_POST_DATA['public_private'];

    $channel_id			= $_POST_DATA['channel'];
    $channel_name 		= $_POST_DATA['channel_name'];
    $sub_cat			= $_POST_DATA['sub_cat'];

    $vid_response 		= $_POST_DATA['vid_response'];
    $response_id 		= $_POST_DATA['response_id'];
    $of_channel_id 		= $_POST_DATA['of_channel_id'];
    $of_channel			= $_POST_DATA['of_channel'];

    /////////////////////////////////////////////////////////////////////
    // run posted tags thru tag word function

    ////////////////////////////////////////////////////////////////////////////////////////////
    // You can now access all the post values from the .param file. eg.     $_POST_DATA['email']; //
    ////////////////////////////////////////////////////////////////////////////////////////////
    # Loop over the post data looking for files and create table elements

    foreach ($_POST_DATA as $post_key => $post_value) {

	if (preg_match("/^upfile_/i", $post_key)) {
      	$uploaded_file_name = $post_value;
        	$uploaded_file_path = $_POST_DATA['upload_dir'] . $uploaded_file_name;

        	if (is_file($uploaded_file_path)) {
            	$file_size = @filesize($uploaded_file_path);
            	$file_size = formatBytes($file_size);
            	clearstatcache();
        	}
    	}
    }

    /////////////////////////////////////////////////////////
   //  Get the post data from the param file (tmp_sid.param)
    /////////////////////////////////////////////////////////

    function getPostData($up_dir, $tmp_sid) {
	$param_array = array();
    	$buffer = "";
    	$key = "";
    	$value = "";
    	$paramFileName = $up_dir . $tmp_sid . ".params";
    	$fh = @fopen($paramFileName, 'r');

    	if (!is_resource($fh)) {
      	kak("<font color='red'>ERROR</font>: Failed to open $paramFileName");
    	}

    	while (!feof($fh)) {
      	$buffer = fgets($fh, 4096);
        	list($key, $value) = explode('=', trim($buffer));
        	$value = str_replace("~EQLS~", "=", $value);
        	$value = str_replace("~NWLN~", "\r\n", $value);

        	if (isset($key) && isset($value) && strlen($key) > 0 && strlen($value) > 0) {
            	if (preg_match('/(.*)\[(.*)\]/i', $key, $match)) {
                		$param_array[$match[1]][$match[2]] = $value;
            } else {
            	$param_array[$key] = $value;
            }
	}
    }

    fclose($fh);

    if (isset($param_array['delete_param_file']) && $param_array['delete_param_file'] == 1) {
	for ($i = 0; $i < 5; $i++) {
      	if (@unlink($paramFileName)) {
            	break;

            } else {
            	sleep(1);
            }
	}
    }
    return $param_array;
    }

    //////////////////////////////////////////////////
    //  formatBytes($file_size) mixed file sizes
    //  formatBytes($file_size, 0) KB file sizes
    //  formatBytes($file_size, 1) MB file sizes etc
    //////////////////////////////////////////////////
    function formatBytes($bytes, $format = 99) {
	$byte_size = 1024;
    	$byte_type = array(" KB", " MB", " GB", " TB", " PB", " EB", " ZB", " YB");

    	$bytes /= $byte_size;
    	$i = 0;

    	if ($format == 99 || $format > 7) {
      	while ($bytes > $byte_size) {
            	$bytes /= $byte_size;
            	$i++;
        	}
    	} else {
      	while ($i < $format) {
            	$bytes /= $byte_size;
            	$i++;
        	}
    	}

    	$bytes = sprintf("%1.2f", $bytes);
    	$bytes .= $byte_type[$i];

    	return $bytes;
    }

    //===============================START OF DATABASE ACTION &   DISPLAY =========================
    //Recording the video files info into dbase

    list($filename, $extension) = split('\.', $uploaded_file_name);

    $filename			= @mysql_real_escape_string($filename);
     $title 			= @mysql_real_escape_string($title);$description		= @mysql_real_escape_string($description); 
    $tags 			= @mysql_real_escape_string($tags);
    $thumbnail      = @mysql_real_escape_string($thumbnail);
    $main_channel		= (int) @mysql_real_escape_string($channel_id);
    $allow_comments 		= @mysql_real_escape_string($allow_comments);
    $allow_embed 		= @mysql_real_escape_string($allow_embed);
    $public_private		= @mysql_real_escape_string($public_private);
    $channel_name		= @mysql_real_escape_string($channel_name);
    $sub_cat_id			= @mysql_real_escape_string($sub_cat);
    $title 			= substr($title, 0, $config_video_title_length);
    $title_seo 			= seo_title($title);

    // from vid reponse form
    $vid_response 		= @mysql_real_escape_string($vid_response);
    $response_id 		= @mysql_real_escape_string($response_id);
    $of_channel_id 		= @mysql_real_escape_string($of_channel_id);
    $of_channel			= @mysql_real_escape_string($of_channel);
    // end vid response form

    if ( $of_channel_id == '' ) $of_channel_id = $main_channel;
    if ( $channel_name == '' ) $channel_name = $of_channel;
    if ( $response_id == '' ) $response_id = 0;



    $sql = "INSERT INTO videos (video_id,
				    response_id,
				    channel_id,
				    sub_channel_id,
				    user_id,
				    viewtime,
				    title,
				    title_seo,
				    description,
				    tags,
				    channel,
				    date_recorded,
				    date_uploaded,
				    location_recorded,
				    thumbnail,
				    video_length,
				    allow_comments,
				    allow_embedding,
				    allow_ratings,
				    rating_number_votes,
				    rating_total_points,
				    updated_rating,
				    public_private,
				    approved,
				    number_of_views,
				    featured,
				    promoted,
				    flag_counter)
			  VALUES ('$uploaded_file_name',
			  	    '$response_id',
			  	    '$of_channel_id',
			  	    '$sub_cat_id',
			  	    '$user_id',
			  	    '0000-00-00 00:00:00',
			  	    '$title',
			  	    '$title_seo',
			  	    '$description',
			  	    '$tags',
			  	    '$channel_name',
			  	    '0000-00-00 00:00:00',
			  	    NOW(),
			  	    '',
			  	    '$thumbnail',
			  	    '00:00:00',
			  	    '$allow_comments',
			  	    '$allow_embedding',
			  	    'yes',
			  	    '0',
			  	    '0',
			  	    '0',
			  	    '$public_private',
			  	    'pending_conversion',
			  	    '0',
			  	    'no',
			  	    'no',
			  	    '0'
			  	    )";

    @mysql_query($sql);


    // update sub-category table

    if ( $sub_cat_id > 0 ) {

	$sql_subs	= "UPDATE sub_channels SET has_vids = 'yes' WHERE sub_channel_id  = '$sub_cat_id'";
	$query_subs	= @mysql_query($sql_subs);
    }


    //============================START OF FFMPEG ACTIONS    ==================================
    // sending command to convertor.php tp convert the movie named : uploaded_file_name ..
    // conversion happens in background so user is not delayed browser window can even  be closed.

    $base_path = installation_paths();
    $convertor = $base_path . '/convertor.php';

    //check if we are debugging so the convertor is called as url
    if ($debugmodex == 1){ //yes debug mode
	header("Location: " . "convertor.php?id=$uploaded_file_name&debug=1");
	die;
    }

    //else load convertor in background
    exec("$path_to_php $convertor $uploaded_file_name> /dev/null &");// (>/dev/null & part    is what sends to background)

    //=================================== START OF TBS DISPLAY    ====================================

    /////////////////////////////////////////
    // V3 video response done via thickbox
    // don't fire up main_1 or site complete

    if ( $vid_response == 'vid_response' ) {
	$template = "themes/$user_theme/templates/response_upload_complete.htm";
    } else {
	$template = "themes/$user_theme/templates/main_1.htm";
	$inner_template1 = "themes/$user_theme/templates/inner_upload_complete.htm";
    }

    $covertor_url = $config["site_base_url"].'/convertor.php'; 
@exec("curl -G $covertor_url > /dev/null &");// (required where background process does not work)

    $TBS = new clsTinyButStrong; 
    $TBS->NoErr = true;
     $TBS->LoadTemplate("$template");
     $TBS->Render = TBS_OUTPUT;
     $TBS->Show();


    @exec("$path_to_php $convertor $uploaded_file_name> /dev/null &");// (>/dev/null &  part is what sends to background)

    @mysql_close();

    die();

    ?>

Well it seems you are attempting to modify PHPKode Newsletter program. If you have a legitimate copy I’m sure their support staff can help you. As far as where I think you should add your image upload processing, it would be at the top of the uploader_finished.php file, so you can use YOUR $thumbnail variable to enter into the DB with the other values. You will probably need to comment out this line (line 33 or so) so that your variable is not overridden.

//$thumbnail            = $_POST_DATA['thumbnail'];

Thanks for your reply. I’m not familiar with that newsletter program, however, when you say “add your image upload processing”, do you mean move this section of code from uploader.php to uploader_finished.php?:

$allowedExts = array("gif", "jpeg", "jpg", "pdf", "png");
$temp = explode(".", $_FILES["file"]["name"]);
$extension = strtolower( end($temp) );
if (!in_array($extension,$allowedExts))
{
echo ("Error - Invalid File Name");
}
$length = 20;
$thumbnail = $_SESSION['user_id'].$_FILES["file"]["name"]; 
move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $thumbnail);
$sql = "INSERT INTO videos ( filename ) VALUES( '$thumbnail' )";
mysql_query($sql);
$file_location = '<a href="http://www.....com/upload/' . $thumbnail . '">' . $thumbnail .      '</a>';

If so, that was not successful.
I look forward to any additional help.
Thanks

Well, it would not include the query section as you will use what is already on the page, but yes.

Thank you for your reply.
I’d like to try your suggestion, but am really not clear on what part to leave in the uploader.php file and what part to add to the uploader_finished.php file.
Any additional help will be appreciated.

Well I’m not about go editing this old file or put any guarantees on this post. I am just placing your upload code, just before the DB insert. I have not edited or removed any video upload code. The video thumbnail variable is being overridden by the image script addition.

<?php

    include_once ('classes/config.php');
    include_once ('classes/sessions.php');
    include_once ('classes/login_check.php');

    //upload include
    require 'uploader_conlib.php';

    $config_video_title_length    = $config['video_title_length'];

    //===================================START OF UPLOADER    (ubber)================================

    $THIS_VERSION = "4.0";

    /////////////////////////////////////////////////////////////////
    // The following possible query string formats are assumed
    //
   // 1. ?upload_dir=tmp_sid&path_to_upload_dir
    // 2. ?cmd=about
    /////////////////////////////////////////////////////////////////

    // Hard-code the 'temp_dir' value here instead of passing it in the address bar.

    $temp_dir    = $_REQUEST['temp_dir']; 
    $_POST_DATA = getPostData($temp_dir, $_REQUEST['tmp_sid']);

    $title             = $_POST_DATA['title'];
    $description         = $_POST_DATA['description'];
    $tags             = $_POST_DATA['tags'];

    $location_recorded    = $_POST_DATA['location_recorded'];
    $thumbnail            = $_POST_DATA['thumbnail'];
    $allow_comments         = $_POST_DATA['allow_comments'];
    $allow_embedding         = $_POST_DATA['allow_embedding'];
    $public_private         = $_POST_DATA['public_private'];

    $channel_id            = $_POST_DATA['channel'];
    $channel_name         = $_POST_DATA['channel_name'];
    $sub_cat            = $_POST_DATA['sub_cat'];

    $vid_response         = $_POST_DATA['vid_response'];
    $response_id         = $_POST_DATA['response_id'];
    $of_channel_id         = $_POST_DATA['of_channel_id'];
    $of_channel            = $_POST_DATA['of_channel'];

    /////////////////////////////////////////////////////////////////////
    // run posted tags thru tag word function

    ////////////////////////////////////////////////////////////////////////////////////////////
    // You can now access all the post values from the .param file. eg.     $_POST_DATA['email']; //
    ////////////////////////////////////////////////////////////////////////////////////////////
    # Loop over the post data looking for files and create table elements

    foreach ($_POST_DATA as $post_key => $post_value) {

    if (preg_match("/^upfile_/i", $post_key)) {
          $uploaded_file_name = $post_value;
            $uploaded_file_path = $_POST_DATA['upload_dir'] . $uploaded_file_name;

            if (is_file($uploaded_file_path)) {
                $file_size = @filesize($uploaded_file_path);
                $file_size = formatBytes($file_size);
                clearstatcache();
            }
        }
    }

    /////////////////////////////////////////////////////////
   //  Get the post data from the param file (tmp_sid.param)
    /////////////////////////////////////////////////////////

    function getPostData($up_dir, $tmp_sid) {
    $param_array = array();
        $buffer = "";
        $key = "";
        $value = "";
        $paramFileName = $up_dir . $tmp_sid . ".params";
        $fh = @fopen($paramFileName, 'r');

        if (!is_resource($fh)) {
          kak("<font color='red'>ERROR</font>: Failed to open $paramFileName");
        }

        while (!feof($fh)) {
          $buffer = fgets($fh, 4096);
            list($key, $value) = explode('=', trim($buffer));
            $value = str_replace("~EQLS~", "=", $value);
            $value = str_replace("~NWLN~", "\r\n", $value);

            if (isset($key) && isset($value) && strlen($key) > 0 && strlen($value) > 0) {
                if (preg_match('/(.*)\[(.*)\]/i', $key, $match)) {
                        $param_array[$match[1]][$match[2]] = $value;
            } else {
                $param_array[$key] = $value;
            }
    }
    }

    fclose($fh);

    if (isset($param_array['delete_param_file']) && $param_array['delete_param_file'] == 1) {
    for ($i = 0; $i < 5; $i++) {
          if (@unlink($paramFileName)) {
                break;

            } else {
                sleep(1);
            }
    }
    }
    return $param_array;
    }

    //////////////////////////////////////////////////
    //  formatBytes($file_size) mixed file sizes
    //  formatBytes($file_size, 0) KB file sizes
    //  formatBytes($file_size, 1) MB file sizes etc
    //////////////////////////////////////////////////
    function formatBytes($bytes, $format = 99) {
    $byte_size = 1024;
        $byte_type = array(" KB", " MB", " GB", " TB", " PB", " EB", " ZB", " YB");

        $bytes /= $byte_size;
        $i = 0;

        if ($format == 99 || $format > 7) {
          while ($bytes > $byte_size) {
                $bytes /= $byte_size;
                $i++;
            }
        } else {
          while ($i < $format) {
                $bytes /= $byte_size;
                $i++;
            }
        }

        $bytes = sprintf("%1.2f", $bytes);
        $bytes .= $byte_type[$i];

        return $bytes;
    }
    
    // ADDED image script here
    $allowedExts = array("gif", "jpeg", "jpg", "pdf", "png");
    $temp = explode(".", $_FILES["file"]["name"]);
    $extension = strtolower( end($temp) );
    if (!in_array($extension,$allowedExts))
    {
    echo ("Error - Invalid File Name");
    }
    $length = 20;
    $thumbnail = $_SESSION['user_id'].$_FILES["file"]["name"]; 
    move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $thumbnail); 

    //===============================START OF DATABASE ACTION &   DISPLAY =========================
    //Recording the video files info into dbase

    list($filename, $extension) = split('\.', $uploaded_file_name);

    $filename        = @mysql_real_escape_string($filename);
    $title             = @mysql_real_escape_string($title);
    $description    = @mysql_real_escape_string($description); 
    $tags             = @mysql_real_escape_string($tags);
    $thumbnail      = @mysql_real_escape_string($thumbnail);
    $main_channel    = (int) @mysql_real_escape_string($channel_id);
    $allow_comments = @mysql_real_escape_string($allow_comments);
    $allow_embed     = @mysql_real_escape_string($allow_embed);
    $public_private = @mysql_real_escape_string($public_private);
    $channel_name    = @mysql_real_escape_string($channel_name);
    $sub_cat_id        = @mysql_real_escape_string($sub_cat);
    $title             = substr($title, 0, $config_video_title_length);
    $title_seo         = seo_title($title);

    // from vid reponse form
    $vid_response         = @mysql_real_escape_string($vid_response);
    $response_id         = @mysql_real_escape_string($response_id);
    $of_channel_id         = @mysql_real_escape_string($of_channel_id);
    $of_channel            = @mysql_real_escape_string($of_channel);
    // end vid response form

    if ( $of_channel_id == '' ) $of_channel_id = $main_channel;
    if ( $channel_name == '' ) $channel_name = $of_channel;
    if ( $response_id == '' ) $response_id = 0;



    $sql = "INSERT INTO videos (video_id,
                    response_id,
                    channel_id,
                    sub_channel_id,
                    user_id,
                    viewtime,
                    title,
                    title_seo,
                    description,
                    tags,
                    channel,
                    date_recorded,
                    date_uploaded,
                    location_recorded,
                    thumbnail,
                    video_length,
                    allow_comments,
                    allow_embedding,
                    allow_ratings,
                    rating_number_votes,
                    rating_total_points,
                    updated_rating,
                    public_private,
                    approved,
                    number_of_views,
                    featured,
                    promoted,
                    flag_counter)
              VALUES ('$uploaded_file_name',
                      '$response_id',
                      '$of_channel_id',
                      '$sub_cat_id',
                      '$user_id',
                      '0000-00-00 00:00:00',
                      '$title',
                      '$title_seo',
                      '$description',
                      '$tags',
                      '$channel_name',
                      '0000-00-00 00:00:00',
                      NOW(),
                      '',
                      '$thumbnail',
                      '00:00:00',
                      '$allow_comments',
                      '$allow_embedding',
                      'yes',
                      '0',
                      '0',
                      '0',
                      '$public_private',
                      'pending_conversion',
                      '0',
                      'no',
                      'no',
                      '0'
                      )";

    @mysql_query($sql);


    // update sub-category table

    if ( $sub_cat_id > 0 ) {

    $sql_subs    = "UPDATE sub_channels SET has_vids = 'yes' WHERE sub_channel_id  = '$sub_cat_id'";
    $query_subs    = @mysql_query($sql_subs);
    }


    //============================START OF FFMPEG ACTIONS    ==================================
    // sending command to convertor.php tp convert the movie named : uploaded_file_name ..
    // conversion happens in background so user is not delayed browser window can even  be closed.

    $base_path = installation_paths();
    $convertor = $base_path . '/convertor.php';

    //check if we are debugging so the convertor is called as url
    if ($debugmodex == 1){ //yes debug mode
    header("Location: " . "convertor.php?id=$uploaded_file_name&debug=1");
    die;
    }

    //else load convertor in background
    exec("$path_to_php $convertor $uploaded_file_name> /dev/null &");// (>/dev/null & part    is what sends to background)

    //=================================== START OF TBS DISPLAY    ====================================

    /////////////////////////////////////////
    // V3 video response done via thickbox
    // don't fire up main_1 or site complete

    if ( $vid_response == 'vid_response' ) {
    $template = "themes/$user_theme/templates/response_upload_complete.htm";
    } else {
    $template = "themes/$user_theme/templates/main_1.htm";
    $inner_template1 = "themes/$user_theme/templates/inner_upload_complete.htm";
    }

    $covertor_url = $config["site_base_url"].'/convertor.php'; 
@exec("curl -G $covertor_url > /dev/null &");// (required where background process does not work)

    $TBS = new clsTinyButStrong; 
    $TBS->NoErr = true;
     $TBS->LoadTemplate("$template");
     $TBS->Render = TBS_OUTPUT;
     $TBS->Show();


    @exec("$path_to_php $convertor $uploaded_file_name> /dev/null &");// (>/dev/null &  part is what sends to background)

    @mysql_close();

    die();

    ?>

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.