/    Sign up×
Community /Pin to ProfileBookmark

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!

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@Sirin86May 09.2008 — Uploading Files: http://www.tizag.com/phpT/fileupload.php

Flash Player for files: http://flowplayer.org/
Copy linkTweet thisAlerts:
@joshlindemauthorMay 09.2008 — 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.
Copy linkTweet thisAlerts:
@Sirin86May 09.2008 — 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:
<i>
</i>//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);

<i> </i>$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/.
×

Success!

Help @joshlindem spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.5,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...