Uploading images / videos to site based off the PHP Novice to Ninja Book


I’ve been building a blogsite based off the code in PHP Novice To Ninja book.

I’m currently trying to add in some capability for users to add in images and videos.

I’m just wondering if anyone has any suggestions on the best way to implement this.

I see two main routes:

  1. get the users to upload the files to a 3rd party hosting platforms such as YouTube and Google Drive, and copy the URLs into a form that can be referenced in the website code.

  2. upload the files directly onto the server and reference from there.

Just wondering if anyone has any input as to which is the most sensible method to implement /any best practices. Or if I’ve missed any other methods.

I see 1) as being easier to code, but I’d dependant on 3rd parties not changing things

That’s the down side of relying on others. A lot of very interesting forum threads have been ruined by Photobucket suddenly deciding to charge for their hosting for cross-linked images (i.e. those linked from other sites, what you are intending to do), and blur / watermark images from those who don’t pay. From then, I’ve tried to upload to the individual forum whenever they offer that option.

The down side is you’ll have to have enough storage space for all the stuff that your users want to upload.

A copyright attorney’s ears just perked up somewhere.

An infinite low cost, highly available storage option is a CDN (content delivery network). A CDN will auto scale to accommodate any data storage need. It will do so at 0 to no cost depending on the vendor. A server hosting media assets is restricted to the storage space of the server. That infrastructure costs real hard cash and even in cloud the cost can be significant because nodes (virtual servers) are leased based on size, cpu. The cost of nodes drastically increases as more cpu and storage is needed. The 0 cost option is a CDN.

Furthermore, with a CDN you can maintain complete control over all assets putting aside the vendor off course. However, assets in a CDN can be lifted shifted to other CDNs fairly easily. Assets stored in a CDN are fairly portable and can easily be moved around.

Also, serving media from servers creates arguably unnecessary architectural complexity and maintainaince. With a CDN all this hassle is eliminated.

With a CDN like AWS s3 + cloudfront you can rest assured that media is safe, highly available, scalable and easily accessed.

I store all my online content inside a CDN set-up like I just described. Never have to worry about a company pulling a fast one like what was described by a previous post.

I even host entire sites on a CDN without a server to deal with. Everything just works don’t have to worry about scaling for traffic, load outages, memory consumption or a complexity and pain of managing a virtual server or god forbid a pyhsical server.

This looks like it might be useful if this is something you want to explore.

Azure, digital ocean, just about any cloud service will have a away to setup a CDN. I’m only familar with AWS though so that is what I can directly recommend.

This is something I have used in the past to easily upload media assets to aws s3.

The docs for the s3 adaptor.


I think this adaptor would allow you store media assets in a gitlab repo and easily upload them. The assets could be served via turning the gitlab repo into a free hosted pages site.


So as you can see there are a lot of modern ways to go about this without resorting to limited self managed server(s) option.

These topics can’t be covered in a book for a beginners. I’m not even sure the CDN option is explored in any php book. The php crowd tends to be very set in their ways. However, if you go outside and take a look around there is an entire world out there with innovation eliminating many pitfalls of cookie cutter php dev.

Thanks for all the input everyone. Plenty to consider. At this stage I’m still learning how to use the php cookie cutter, but will look into the CDN route.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.