Wrox Programmer Forums
|
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 1st, 2008, 03:38 AM
Registered User
 
Join Date: Aug 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default php script

i am creating a website for video sharing. i have installed xampp on my pc
1) i need a script to upload videos
2) i need a script to convert the uploaded videos of any format into flash
3) i need to know how to create a database to store these videos
4) once stored how should i create the thumbnails
5) how should i stream the videos

m29
 
Old September 13th, 2008, 01:53 AM
Registered User
 
Join Date: Aug 2008
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to toraj58
Default

I can help you for the first part.
i have already written a function for uploading pictures that can be used for uploading any kind of format with a little changes in source.
it can give you the clue.
here is the code for the function:

Code:
function uploadimage($name, $file, $tablename, $dir, $username)
{
$debug = false;

$maxwidth = 300;
$maxheight = 300;

$image_caption = $name;
$image_username = $username;
$image_tempname = $file['name'];
$filename = $file['name'];
$tmpname = $file['tmp_name'];

if ($debug)
{
    list($width, $height, $type, $attr) = getimagesize($tmpname);
    echo "<span class = debug>";
    echo "<p >Debug info: <p />";
    echo $image_tempname;
    echo "<br />";
    echo $tmpname;
    echo "<br />";
    echo "image width and height are: " . $width . "*" . $height;
    echo "</span>";
    die();
}

$today = date("Y-m-d");
//upload image and check for image type
//make sure to change your path to match your images directory
//$ImageDir ="D:/Program Files/Apache Software Foundation/Apache2.2/htdocs/nmpfrance2/images2/";   
$ImageDir = $dir;
$ImageName = $ImageDir . $image_tempname;

list($width, $height, $type, $attr) = getimagesize($tmpname);

if ($width > $maxwidth || $height > $maxheight)
{
    unlink($tmpname);
    echo "<p><span class = error> Image Width and Height should be equal or less than 300 pixels </span><p />";
    echo "<a href = 'javascript:history.back()' class = activelink> Select another image </a>";
    die();
}

if (move_uploaded_file($tmpname, $ImageName)) 
{
    //get info about the image being uploaded
    list($width, $height, $type, $attr) = getimagesize($ImageName);
    switch ($type) 
    {
        case 1:
        $ext = ".gif";
        break;
        case 2:
        $ext = ".jpg";
        break;
        case 3:
        $ext = ".png";
        break;
        default:
        echo "Sorry, but the file you uploaded was not a GIF, JPG, or " .
        "PNG file.<br>";
        echo "Please hit your browser's 'back' button and try again.";

        echo "<br>or click<a href='javascript:history.back()'> here</a>!";
        die();
    }
    //insert info into image table
    $insert = "INSERT INTO $tablename
    (image_caption, image_username, image_ext,image_date)
    VALUES
    ('$image_caption', '$image_username', '$ext','$today')";
    $insertresults = mysql_query($insert)
    or die(mysql_error('Can not insert image record!'));
    $lastpicid = mysql_insert_id();

    $dotindex = strpos($filename, '.', 0 );
    $filename = substr($filename, 0, $dotindex);
    $filename = $filename . $lastpicid . $ext;

    $update = "update $tablename set saved_name = '$filename' where image_id = $lastpicid";
    $upres = mysql_query($update) or die('<span class = error> Can not update image record!!!</span>');

    $newfilename = $ImageDir . $filename;

    ///// if the file exist then this code can not raname it
    ////  instead it will copy newfile with newname and then remove(unlink oldfile)

     if (!rename($ImageName, $newfilename)) 
     {
        if (copy ($ImageName, $newfilename)) 
        {
            unlink($ImageName);
        }
    }
}
return $lastpicid;
}
Touraj Ebrahimi [toraj_e] [at] [yahoo] [dot] [com]

 
Old October 5th, 2008, 06:53 PM
Authorized User
 
Join Date: Oct 2008
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi

the best way i can think of for you is to use youtube service

you need to you tube api service.

if you have enough budget and dedicated servers and resource.
post your question again with details.

Thanks

http://FindaJobSearch.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
send variables from a PHP script..... ethantinder Beginning PHP 2 June 23rd, 2008 02:45 PM
Putting PHP in a C++ script Waffles Beginning PHP 2 August 8th, 2007 06:49 AM
PHP Login script problem columbo1977 Beginning PHP 1 May 21st, 2006 10:47 PM
Can anyone help with this php script plz benzspida Beginning PHP 3 May 11th, 2006 05:54 AM
Call and run CGI script from a PHP script ... how? dbruins BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 1 June 10th, 2003 03:09 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.