Reply
????How to I write the results of an upload to mysql????
Old 06-01-2008, 12:28 PM ????Please take a look....write the results of an upload to mysql????
goheadtry's Avatar
Webmaster Talker

Posts: 715
Name: John
Location: United States of America, California
This is an upload script which then converts the uploaded format of the video to flv and a still frame as a jpg. I know want to make it so that the script will write the information to a mysql table know that the information is done.


I have some idea of the insert code, but I am unsure of how to implement it in the current script:
PHP Code:
$sql 'INSERT INTO `forbushj_onetest`.`video` (`id`, `title`, `descr`, `pic`, `locat`, `src`) VALUES (\'222\', \'test\', \'test\', \'test.jpg\', \'test.flv\', \'http://test.com\');' 
table item id is the number id of the movie and needs to be one number higher then the previous movie
table item title is the title of the movie.
table item descr isthe description of the movie
table item pic is the filename without the path of the screenshot jpeg
table item locat is the filename of the video without the path
table item src is the creator of the videos website



PHP Code:
<?php
//home/forbushj/www/vidtemp/
$target "vidtemp/";
$target $target basename$_FILES['uploaded']['name']) ;
$ok=1;
$output .= date("Y-m-d-H-i-s")

//This is our size condition
if ($uploaded_size 350000)
{
echo 
"Your file is too large.<br>";
$ok=0;
}

//This is our limit file type condition
if (!($uploaded_type=="video/x-ms-asf")) {
echo 
"You may only upload movies.<br>";
$ok=0;
}

//Here we check that $ok was not set to 0 by an error
if ($ok==0)
{
Echo 
"Sorry your file was not uploaded";
}

//If everything is ok we try to upload it
else
{
if(
move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
{
//COnvert the video
//echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded";
exec('ffmpeg -i 'basename$_FILES['uploadedfile']['name']).' -an -ss 00:00:03 -t 00:00:01 -r 1 -y -s 150x100 -f mjpeg /home/forbushj/www/pic/video/'.$output.'.jpg');
exec('ffmpeg -i 'basename$_FILES['uploadedfile']['name']).' -ar 22050 -ab 32 -f flv -s 320x240 /home/forbushj/www/vidd/'.$output.'.flv');
}
else
{
echo 
"Sorry, there was a problem uploading your file.";
}
}
?>

Last edited by goheadtry : 06-01-2008 at 05:11 PM.
goheadtry is offline
Reply With Quote
View Public Profile Visit goheadtry's homepage!
 
When You Register, These Ads Go Away!
Old 06-01-2008, 11:14 PM Re: ????How to I write the results of an upload to mysql????
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
Wireless Audio
Posts: 2,322
Name: Keith Marshall
Location: West Hartford, CT
PHP Code:
<?php
  
  $filepath 
'/home/forbushj/www/vidtemp/';
  
$filetypes = array('video/x-ms-asf''video/x-msvideo''video/x-flv''video/quicktime''video/mp4''video/mpeg''video/x-ms-wmv');
  
$error_msg '';
  
  
// Check for errors:
  
if ($uploaded_size 350000$error_msg .= 'Your file is too large.<br />';
  if (!
in_array($uploaded_type$filetypes)) $error_msg .= 'You may only upload movies.<br />';
  
  if (
$error_msg)
  {
    echo 
$error_msg 'Sorry your file was not uploaded';
  }
  else if (
move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
  {
    
$file $_FILES['uploaded']['tmp_name'];
    
$ext substr($file, ((strrpos($file'.') !== false) ? strrpos($file'.') : strlen($file)), strlen($file));
    
$filename date('Y-m-d-H-i-s') . '_' str_replace(' ''_'basename($file$ext));
    
$filename preg_replace('/[\\\/:*?"<>|]/'''$filename);
    
    if (
is_file($filepath $file))
    {
      
$output = array();
      
      
exec('ffmpeg -i "' escapeshellarg($file) . '" -an -ss 00:00:03 -t 00:00:01 -r 1 -y -s 150x100 -f mjpeg "/home/forbushj/www/pic/video/' escapeshellarg($filename) . '.jpg"'$output$exit_code_pic);
      
exec('ffmpeg -i "' escapeshellarg($file) . '" -ar 22050 -ab 32 -f flv -s 320x240 "/home/forbushj/www/vidd/' escapeshellarg($filename) . '.flv"'$output$exit_code_vid);
      
      if (!
is_array($output)) $error_msg 'Sorry, there was a problem uploading your file.';
      
      if (
$exit_code)
      {
        
error_log('ffmpeg exec returned ' $exit_code);
        
$error_msg 'Sorry, there was a problem uploading your file.';
      }
      
      if (!
$error_msg)
      {
        
mysql_query("
          INSET INTO forbushj_onetest.video (title, descr, pic, locat, src)
          VALUES (
            '" 
mysql_real_escape_string($title) . "',
            '" 
mysql_real_escape_string($descr) . "',
            '" 
mysql_real_escape_string($filename ".jpg") . "',
            '" 
mysql_real_escape_string($filename ".flv") . "',
            '" 
mysql_real_escape_string($src) . "'
          )
        "
);
      }
    }
    else
    {
      
$error_msg 'Sorry, there was a problem uploading your file.';
    }
  }
  else
  {
    
$error_msg 'Sorry, there was a problem uploading your file.';
  }
  
  if (
$error_msg) echo $error_msg;
  
?>
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 06-02-2008, 06:15 PM Re: ????How to I write the results of an upload to mysql????
goheadtry's Avatar
Webmaster Talker

Posts: 715
Name: John
Location: United States of America, California
I forgot one thing. Where do I put the command to loginto mysql and log off of mysql?
goheadtry is offline
Reply With Quote
View Public Profile Visit goheadtry's homepage!
 
Old 06-02-2008, 06:27 PM Re: ????How to I write the results of an upload to mysql????
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
Wireless Audio
Posts: 2,322
Name: Keith Marshall
Location: West Hartford, CT
That can be anywhere before the query - from the top of the script page or before the query call
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to ????How to I write the results of an upload to mysql????
 

Thread Tools

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.12936 seconds with 12 queries