upload video convert it to flv and then move the file to a folder

how to move the file to a folder in the root directory

Page 1 of 1

2 Replies - 6006 Views - Last Post: 10 June 2009 - 04:34 AM Rate Topic: -----

#1 ebot  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 15-November 08

upload video convert it to flv and then move the file to a folder

Posted 07 June 2009 - 01:38 AM

i got a problem moving the converted flv and thumbnail photo to the folder in the root directory;
here are my codes that does the convertions, everything is fine, convertioin done and store in the db:
$ffmpegpath = "../tool/ffmpeg.exe";

function converttoflv( $in, $out )
{
  unlink( $out );
  $cmd = "$ffmpegpath -v 0 -i $in -ar 11025 $out 2>&1";
  $fh = popen( $cmd, "r" );
  while( fgets( $fh ) ) { }
  pclose( $fh );
}

function getthumbnail( $in, $out )
{
  unlink( $out );
  $cmd = "$ffmpegpath -i $in -pix_fmt rgb24 -vframes 1 -s 300x200 $out 2>&1";
  $fh = popen( $cmd, "r" );
  while( fgets( $fh ) ) { }
  pclose( $fh );
}

function flv_import( $upfile, $fname, $title )
{
  $fname = preg_replace( '/\..*$/', '', basename( $fname ) );
  $target = "../video/"; 
  $target = $target . basename( $_FILES['vid']['name']);
  
  $flvpath = "$fname.flv";
  $thumbpath = "$fname.gif";
  
  converttoflv( $upfile, "videos\\$flvpath" );
  getthumbnail( $upfile, "videos\thumbs\\$thumbpath" );
  
   $DateAdded = date("Y-m-d H:i:s");
  $sql = "INSERT INTO videos (name, thumb, video_path, eng, fr, ger, date_added) " .
			"VALUES (\"$title\", \"$thumbpath\", \"$flvpath\", \"$eng\", \"$fr\", \"$ger\", \"$DateAdded\")";
		$result = mysql_query($sql) or die("Error: " . mysql_error());
}




the problem now is , i get a message: "


Warning: unlink(videos\29052009012.flv) [function.unlink]: No such file or directory in C:\xampp\htdocs\toura\internal\video.php on line 16

Warning: unlink(videos humbs\29052009012.gif) [function.unlink]: Invalid argument in C:\xampp\htdocs\toura\internal\video.php on line 25" :crazy:

and the video and thumbnails files are not moved to the folders i'd want,
i will appreciate any help and information. :blink:
thanks
Ebot Evans

Is This A Good Question/Topic? 0
  • +

Replies To: upload video convert it to flv and then move the file to a folder

#2 Wimpy  Icon User is offline

  • R.I.P. ( Really Intelligent Person, right? )
  • member icon

Reputation: 159
  • View blog
  • Posts: 1,038
  • Joined: 02-May 09

Re: upload video convert it to flv and then move the file to a folder

Posted 07 June 2009 - 04:37 AM

You could use move_uploaded_file() and move the file on upload! :)

View Postebot, on 7 Jun, 2009 - 10:38 AM, said:

i got a problem moving the converted flv and thumbnail photo to the folder in the root directory;
here are my codes that does the convertions, everything is fine, convertioin done and store in the db:
$ffmpegpath = "../tool/ffmpeg.exe";

function converttoflv( $in, $out )
{
  unlink( $out );
  $cmd = "$ffmpegpath -v 0 -i $in -ar 11025 $out 2>&1";
  $fh = popen( $cmd, "r" );
  while( fgets( $fh ) ) { }
  pclose( $fh );
}

function getthumbnail( $in, $out )
{
  unlink( $out );
  $cmd = "$ffmpegpath -i $in -pix_fmt rgb24 -vframes 1 -s 300x200 $out 2>&1";
  $fh = popen( $cmd, "r" );
  while( fgets( $fh ) ) { }
  pclose( $fh );
}

function flv_import( $upfile, $fname, $title )
{
  $fname = preg_replace( '/\..*$/', '', basename( $fname ) );
  $target = "../video/"; 
  $target = $target . basename( $_FILES['vid']['name']);
  
  $flvpath = "$fname.flv";
  $thumbpath = "$fname.gif";
  
  converttoflv( $upfile, "videos\\$flvpath" );
  getthumbnail( $upfile, "videos\thumbs\\$thumbpath" );
  
   $DateAdded = date("Y-m-d H:i:s");
  $sql = "INSERT INTO videos (name, thumb, video_path, eng, fr, ger, date_added) " .
			"VALUES (\"$title\", \"$thumbpath\", \"$flvpath\", \"$eng\", \"$fr\", \"$ger\", \"$DateAdded\")";
		$result = mysql_query($sql) or die("Error: " . mysql_error());
}




the problem now is , i get a message: "


Warning: unlink(videos\29052009012.flv) [function.unlink]: No such file or directory in C:\xampp\htdocs\toura\internal\video.php on line 16

Warning: unlink(videos humbs\29052009012.gif) [function.unlink]: Invalid argument in C:\xampp\htdocs\toura\internal\video.php on line 25" :crazy:

and the video and thumbnails files are not moved to the folders i'd want,
i will appreciate any help and information. :blink:
thanks
Ebot Evans

Was This Post Helpful? 0
  • +
  • -

#3 Ghost rider  Icon User is offline

  • D.I.C Head

Reputation: -5
  • View blog
  • Posts: 158
  • Joined: 29-October 08

Re: upload video convert it to flv and then move the file to a folder

Posted 10 June 2009 - 04:34 AM

hey there,
I managed to create a script that upload image in directory and image details on database also automatically create a thumbnail of image.
I want to do the same to vidoes file. Could you please direct me how to do it? Thank in advance
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1