PHP Video Upload

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mikefuss
    New Member
    • Dec 2007
    • 3

    PHP Video Upload

    I'm having trouble getting my PHP code to upload videos. I have a page that uploads Images, which uploads to a table called Photos and everything works fine. I tried modifying that code to upload videos to a table called Videos, but I don't see the files in the folder that I assigned it to. There are no errors when I upload the file, and the file size and type is within the conditions that I set. Any suggestions, this is my code:

    function valid($img_ext) {
    $ext = array(
    //ext types
    'video/wmv' => 'wmv',
    'video/mov' => 'mov',
    );

    if(array_key_ex ists($img_ext, $ext)){
    return true;
    break;
    }
    else
    return false;
    }

    if(valid($_FILE S['uploadvideo']['type']) == true){

    if ($_FILES["uploadvide o"]["size"] < 10240000){
    if ($_FILES["uploadvide o"]["error"] == false){
    //Uploads and stores in temporary location for further verification
    $_FILES["uploadvide o"]["$name"];
    $_FILES["uploadvide o"]["tmp_name"];

    if (file_exists("V ideos/Orig/".$_FILES["uploadvide o"]["name"])){
    echo $_FILES["uploadvide o"]["name"], " already exists. ";
    }
    else{
    move_uploaded_f ile($_FILES["uploadvide o"]["tmp_name"], "Videos/Orig/" . $_FILES["uploadvide o"]["name"]);
    //calls the thumbnail maker function
    //imageThmb();
    $src = $_FILES["uploadvide o"]["name"];
    $thumb = "thmb_".basenam e($_FILES['uploadvideo']['name']);
    mysql_query("IN SERT INTO `ttakara`.`Vide os` (`ID` ,`name`, `description` ,`Link_Orig` ,`Link_Thumb` ,`approve`, `User_ID` ) VALUES ('' , '$name', '$description', '$src', '$thumb', 0, '');");
    }
    }
    //Prints an error if image failed to upload
    else{
    echo "Error: ".$_FILES["uploadvide o"]["error"]."<br />";
    }
    }
    else{
    //alerts user that the image is too large
    echo "<script>alert( 'The image you are trying to upload is too large.')</script>";
    }
    }
  • mikefuss
    New Member
    • Dec 2007
    • 3

    #2
    Originally posted by mikefuss
    I'm having trouble getting my PHP code to upload videos. I have a page that uploads Images, which uploads to a table called Photos and everything works fine. I tried modifying that code to upload videos to a table called Videos, but I don't see the files in the folder that I assigned it to. There are no errors when I upload the file, and the file size and type is within the conditions that I set. Any suggestions, this is my code:

    function valid($img_ext) {
    $ext = array(
    //ext types
    'video/wmv' => 'wmv',
    'video/mov' => 'mov',
    );

    if(array_key_ex ists($img_ext, $ext)){
    return true;
    break;
    }
    else
    return false;
    }

    if(valid($_FILE S['uploadvideo']['type']) == true){

    if ($_FILES["uploadvide o"]["size"] < 10240000){
    if ($_FILES["uploadvide o"]["error"] == false){
    //Uploads and stores in temporary location for further verification
    $_FILES["uploadvide o"]["$name"];
    $_FILES["uploadvide o"]["tmp_name"];

    if (file_exists("V ideos/Orig/".$_FILES["uploadvide o"]["name"])){
    echo $_FILES["uploadvide o"]["name"], " already exists. ";
    }
    else{
    move_uploaded_f ile($_FILES["uploadvide o"]["tmp_name"], "Videos/Orig/" . $_FILES["uploadvide o"]["name"]);
    //calls the thumbnail maker function
    //imageThmb();
    $src = $_FILES["uploadvide o"]["name"];
    $thumb = "thmb_".basenam e($_FILES['uploadvideo']['name']);
    mysql_query("IN SERT INTO `ttakara`.`Vide os` (`ID` ,`name`, `description` ,`Link_Orig` ,`Link_Thumb` ,`approve`, `User_ID` ) VALUES ('' , '$name', '$description', '$src', '$thumb', 0, '');");
    }
    }
    //Prints an error if image failed to upload
    else{
    echo "Error: ".$_FILES["uploadvide o"]["error"]."<br />";
    }
    }
    else{
    //alerts user that the image is too large
    echo "<script>alert( 'The image you are trying to upload is too large.')</script>";
    }
    }
    Can anyone help me please, really urgent!

    Comment

    • Markus
      Recognized Expert Expert
      • Jun 2007
      • 6092

      #3
      Is everything gettting inserted into the `videos` table?

      Comment

      • mikefuss
        New Member
        • Dec 2007
        • 3

        #4
        no records are actually being inserted into the table, but I know that code is right because as soon as I change the type from video to image, everything works for images.

        Comment

        • Markus
          Recognized Expert Expert
          • Jun 2007
          • 6092

          #5
          Are videos passed through the $_FILES array?

          I'll have a check!

          Yes they are - silly me.

          Hmmm, have you tried increasing the

          $_FILES["uploadvide o"]["size"] < 10240000){

          ?

          Comment

          • bnvnv

            #6
            Are videos passed through the $_FILES array?

            I'll have a check!

            Yes they are - silly me.

            Hmmm, have you tried increasing the

            $_FILES["uploadvide o"]["size"] < 10240000){

            Comment

            Working...