www.webdeveloper.com
Results 1 to 4 of 4

Thread: PHP+SQL+File Upload

  1. #1
    Join Date
    Jul 2005
    Posts
    23

    PHP+SQL+File Upload

    I have a job lined up requiring something new for me. The client wants to have the ability to put daily videos up on his website. All these videos will be converted to flash before putting them on the website. He tells me each video will be approimately 10-15min. I've been doing some searching, but so far haven't really found what I'm looking for.

    I do know that I can purchase a "PHP UPLOAD2" from DMXZone program that can do this, but I was thinking this should be something I can do myself.

    So here's what I'm trying to do.

    1) Create a page to upload the file. This will include an HTML based page with a name field and also the file upload, and then submit it.
    2) Then a PHP page will dump the file into a 'video' folder, and place the name and location into an SQL database.
    3) Over on the display page I have a different problem.
    3a) I will place an imageholder on the spot where the flashvideo will play
    3b) Under this video spot, will be an entire list of the videos given by name (the name field from the upload). This would be done by a pull from the SQL database
    3c) Upon clicking one of this links, it will play that video in the video holder spot.

    This upload section will be in a sql-based "user authentication" part of the website. So there is some security there, and I will make it so it only uploads flash files.

    Some direction would be most helpful. Perhaps pointing to some tutorials that you think best fit this scenario. I've been finding tutorials on 'picture uploads' similar to what I'm going for, though I know I'd have to increase the size limitations that they have placed in those. Just trying to get some further insight on this.

    Thanks!

  2. #2
    Join Date
    May 2008
    Location
    Montreal
    Posts
    26
    Uploading Files: http://www.tizag.com/phpT/fileupload.php
    Flash Player for files: http://flowplayer.org/

  3. #3
    Join Date
    Jul 2005
    Posts
    23
    Thanks for that Siren.

    That flashplayer looks handy. That and it was a fun video to watch.

    As for the 'uploading files' link you sent. I have been reading through that one. It's got the basics for file uploading, but doesn't talk much to attaching it to an SQL database.

    So file uploading I will get going just to get the basics out of the way, but I will still need to figure out how to attach it to an SQL database, and then to figure out a way to display everything in the database to a page so users can pick and choose which videos they want to watch.

  4. #4
    Join Date
    May 2008
    Location
    Montreal
    Posts
    26
    You can't attach a file to an SQL database. You can insert the file into the database, but this is a bad way to go with video files since they're huge. You can insert a row into the database for this video using SQL. Like with MySQL:
    Code:
    //file upload stuff
    $filename = the filename for the video where you move it to
    
    if (move_uploaded_file($_FILES["name"]["tmp_name"], $filename)){
        $sql = "INSERT INTO videos (filename) VALUES ('" . $filename . "')";
        mysql_query($sql);
    
        $video_id = mysql_insert_id();
    }
    This will insert the video info into the database, and give you the ID of the newly inserted video.

    You'll need to learn how to interact with a database using SQL. The site I gave you before has a tutorial on how to use MySQL (the most common free database) with PHP: http://www.tizag.com/mysqlTutorial/.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles