Member Avatar for megachip04

I am trying to let users upload .flv files that will be played through flow player. While I am not getting an error, the file is not copying to the ftp folder. The upload script I have is

if ($_FILES["file1"]["type"] == "video/flv")
  {
$path1 = "uploads/".time().'.'.$HTTP_POST_FILES['file1']['name'];
$path1 = str_replace (" ", "", $path1);
$path1 = str_replace("#", "No.", $path1); 
$path1 = str_replace("$", "Dollar", $path1); 
$path1 = str_replace("%", "Percent", $path1); 
$path1 = str_replace("^", "", $path1); 
$path1 = str_replace("&", "and", $path1); 
$path1 = str_replace("*", "", $path1); 
$path1 = str_replace("?", "", $path1); 

if ($_FILES["file1"]["error"] > 0)
  {
  header("location:video.php");
  die();
  }
else
  {
  copy($_FILES["file1"]["tmp_name"],$path1);
  }
  }

Try to add video/x-flv to the conditional statement.

Member Avatar for megachip04

Try to add video/x-flv to the conditional statement.

this seems to have done the trick, could you explain what the x- means?

Great! :) On linux there is the command file that gives you the correct mime-type for each file:

file --mime video.flv

the result is video.flv: video/x-flv; charset=binary

Member Avatar for diafol

$HTTP_POST_FILES is T.Rex's extinct uncle (deprecated 4.1.0). Try $_FILES instead.

One more suggestion, instead of this many str_replaces, use arrays to replace the relevant chars.

Member Avatar for megachip04

One more suggestion, instead of this many str_replaces, use arrays to replace the relevant chars.

how might that be done?

This way:

$a = array(' ','#','$','%','^','&','*','?');
$b = array('','No.','Dollar','Percent','','and','','');
$path1 = str_replace($a,$b,$path1);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.