How to upload videos to database

Videos are incredibly resource hungry and unless you are paying for a fast server with lots of memory your users are going to be very disappointed with the results.

Have you considered creating a YouTube account and uploading the videos? All that is necessary is to include the following link in your web page:

// “YouTube Shared embedded” link copied and pasted

      width="560" height="315"
      allow="autoplay; encrypted-media" 


I have and that is going to be my first idea but i got a free hosting with unlimited memory and unlimited bandwidth…there is a tutorila by mmtutus on how to upload files in php lesson 52 or 53…

Sounds like a fantastic deal.

I would be tempted to compare rendering the uploaded videos against Youtube rendering and report your findings.

Even if I had great server storage and bandwidth I would still tend to want to take advantage of youtube doing the different codecs / formats for me.


If you have a browse down this forum a bit, there are quite a few threads discussing file uploads of varying kinds.

If it sounds too good to be true, it probably is. Free hosting is great for testing, but I don’t know anyone who would advise its use for a live site - especially not the kind of site you are planning.

This post might be helpful:
Access Restricted video hosting - #2 by SamA74

1 Like

The service is called… I would like your opinion on that service…

I have no personal experience of it but:
(a) it has a poor WOT rating
(b) there is no contact information on the site
(c) there is nothing on the site to indicate the owner
(d) the domain is registered with privacy protect, so again, no information about the business owner
(e) there is nothing to say where the business is based and therefore which country’s law govern the business

How will you contact them if there is a problem with your site? What support do they offer? (If people are paying for access to your content, and are unable to access it, they may start asking for refunds if the situation is not swiftly resolved.)

Based on that, I wouldn’t go near them, and I most certainly wouldn’t use them (or, indeed, any other “free” hosting) to host a paid service.

Just my tuppence-worth.


The lack of information on who is behind it stinks a lot of them having something to hide.
The WOT page on them seems to corroborate that idea. It mentions phishing, scams, fake, and is marked as unsafe.
If your paying customers are trusting your site with their data, can you trust your host with it?

^ This!

I only got this far checking it out:-

This site requires Javascript to work, please enable Javascript in your browser or use a browser with Javascript support

I don’t like to visit iffy sites with js on.

My opinion: Stay well away from them.

1 Like

Thanks for the opinion guys… but with regard to providing offline video tutorials, how does one go about in doing this if I have a good host? Do I need to upload to the folder in the htdoc? Can just create a folder called videos?

Offline? Just provide links to the various formats of each file and let them download for viewing later when offline.

Sorry for the confusion… i would just like to embed the videos on my website so that the user can watch it… i guess i will use the src html code but do i need to upload this into any particular folder? I guess i can call it videos in my htdoc folder but not sure how to enable user to download it…

But with the video link, they can only watch it right and not download it?

Just don’t go there. Uploading videos and getting them to play for all different flavours of browsers out there is a royal pain in the ass and very resource intensive. Just use YouTube or vimeo. They’ve solved all those problems for you.


By the time they are able to watch it, it has already by necessity been downloaded to their browser. Not that everyone would know how to save it or that anyone would share the link so that others could watch it, but you don’t want to make it too easy to do. Hosting the videos in youtube or vimeo etc. could save you from a lot of headaches if you’re concerned about that.


But i only want to put some free videos on youtube and the rest can only be accessed when the user has paid for it…

Did you read the link I gave you in post #7? It shows that Vimeo Pro provides various options for restricting access to videos.


Yes, and their prices seem very reasonable, $2O, $34, $50 per month depending on the need.

Videos are not an easy thing to deal with. They take up a lot of space and need to be converted to several different formats to be compatible with various browsers. Setting up video processing at the server level is a huge pain and typically requires admin level permissions to add libraries to the server. I think the best approach is using a cloud vendor like AWS that has services for manipulating videos and creating all the various formats that are needed. Using Vimeo also seems like a good solution. Storing and converting/encoding videos to all the various formats is a company/service within itself. If you are the only one uploading videos than perhaps it can be done manually but otherwise its best to use a vendor who specializes in managing videos. There is no way you will get away with using free hosting if you want to upload and encode those videos without a separate vendor who manages that process for you. Unless you do it all manually.

1 Like

How would I go about in uploading videos if I am the only one doing it? I am thinking about giving myself a permission called admin, where I can access these codes:

if (isset($_POST['submit'])) {
	$file = $_FILES['file'];

	$fileName = $_FILES['file']['name'];
	$fileTmpName = $_FILES['file']['tmp_name'];
	$fileSize = $_FILES['file']['size'];
	$fileError = $_FILES['file']['error'];
	$fileType = $_FILES['file']['type'];

	$fileExt = explode('.', $fileName);
	$fileActualExt = strtolower(end($fileExt));

	$allowed = array('jpg', 'jpeg', 'png', 'pdf');

	if (in_array($fileActualExt, $allowed)) {
		if ($fileError === 0) {
           if ($fileSize < 1000000) {
              $fileNameNew = uniqid('', true).".".$fileActualExt;
              $fileDestination = 'uploads/'.$fileNameNew;
              move_uploaded_file($fileTmpName, $fileDestination);
              header("Location: index.php?uploadsuccess");
           } else {
           	   echo "Your file is too big!";
		} else {
			echo "There was an error uploading your file!";
	} else {
		echo "You cannot upload files of this type!";

At the moment, I would need to change the file extension type to include video fomat with avi files etc but got this from mmtuts tutorial… Would I need to create a folder in the htdocs in any live webhosting?

That won’t work, because browsers cannot play avi files. This is what we’ve been trying to tell you the whole time. Playing video in browsers is hard, which is why you’d be a lot better off paying for Vimeo than doing all of this yourself.

But if you insist, I suggest you read (not scan, read!) this article