need a video upload script

Discussion in 'PHP' started by dracula51, May 14, 2009.

  1. #1
    can anyone help me to create a video upload script with php5

    >> when someone upload a video file...suppose video1.wmv...it'll upload it to a tmp folder..then pass to FFMPEG...ffmpeg will convert it with exec command & store it another folder with renaming it from video1.wmv (now video1.flv as it converted) to a random name like d5g45d4.flv

    i need such a script

    plz help me
     
    dracula51, May 14, 2009 IP
  2. Syndrom

    Syndrom Peon

    Messages:
    89
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    we can help you, but you should start yourself and ask where your problems are.

    Short Guide:
    Create a HTML form with <form enctype="multipart/form-data" method="post">
    <input type="file" name="video" />

    Create a php file that handles the file upload, afterwards convert it.
     
    Syndrom, May 14, 2009 IP
  3. dracula51

    dracula51 Peon

    Messages:
    146
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    ok. tomorrow i'll start & tell u when i'll face problem :)
     
    dracula51, May 14, 2009 IP
  4. dracula51

    dracula51 Peon

    Messages:
    146
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    here's the code i tried (i ignore here ffmpeg convertation code) here just file upload & random rename code

    first i write a html file (index.htm)
    <html>
    
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>Please choose a file</title>
    </head>
    
    <body>
    <form enctype="multipart/form-data" action="upload.php" method="POST">
    Please choose a file: <input name="uploaded" type="file" size="20" /><br />
    <input type="submit" value="Upload" />
    </form>
    </body>
    
    </html>
    HTML:
    & my php file (upload.php) is
    <?php 
    $target = "tmp/"; //make sure there's a "tmp" folder at ur root server
    $target = $target . basename( $_FILES['uploaded']['name']) ; 
    $ok=1; 
    
    //This is the size condition 
    if ($uploaded_size > 3500000) 
    { 
    echo "Your file is too large.<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"; 
    } 
    else 
    { 
    if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) 
    { 
    echo "The file ". basename( $_FILES['uploaded']['name']). " has been uploaded"; 
    } 
    else 
    { 
    echo "Sorry, there was a problem uploading your file."; 
    } 
    } 
    
    // ##############################################
    // Its OK till here, then the below codes do not working
    // ##############################################
    
    
    //This function separates the extension from the rest of the file name and returns it 
    
    function findexts ($filename) 
    { 
    $filename = strtolower($filename) ; 
    $exts = split("[/\\.]", $filename) ; 
    $n = count($exts)-1; 
    $exts = $exts[$n]; 
    return $exts; 
    } 
    
    //This applies the function to our file 
    $ext = findexts ($_FILES['uploaded']['name']) ;
    
    //This line assigns a random number to a variable. You could also use a timestamp here if you prefer. 
    $ran = rand () ;
    
    //This takes the random number (or timestamp) you generated and adds a . on the end, so it is ready of the file extension to be appended.
    $ran2 = $ran.".";
    
    //This assigns the subdirectory you want to save into... make sure it exists!
    $target = "flv/";  //make sure there's a "flv" folder at ur root server
    
    //This combines the directory, the random file name, and the extension
    $target = $target . $ran2.$ext;
    
    if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) 
    {
    echo "The file has been uploaded as ".$ran2.$ext;
    } 
    else
    {
    echo "Sorry, there was a problem uploading your file.";
    }
    ?>
    PHP:
    the first part of the php file is working...means i can upload a file but the 2nd part (rename to a random name) isn't working

    plz help me
     
    dracula51, May 14, 2009 IP