Posted Dec 29, 08:09 AM

Writing a re-usable file upload class in PHP

At work, the advertising department sometimes uses what they call “splash pages” when an advertiser wants to advertise on the website but doesn’t have a website of their own to link to. A splash page is just a simple web page with a single image on it. It’s usually a copy of the print ad.

So when they needed a splash page, they would send me the jpeg, I would create a quick and simple web page with it, upload the .html file and the jpeg into a folder on the webserver, then send them the URL for the page.

I wanted to make it possible for them to bypass me completely, so I needed a user-friendly web form that would accept a jpeg file upload, create a web page, and then display the final URL for the user.

I decided that, rather than look for a pre-existing tool to do this, I would take the opportunity to write a secure and robust file upload class that I could use again in future projects.

php secure file uploading class

As a side note, I also used Sublime Text 3 for the project, to give it a good trial run. I like it quite a bit. I have used a bunch of different code editors, from BBEdit, to TextMate, even vi. BBEdit is still the one that does everything well and never fails, but it doesn’t have the nice code-completion features that Sublime has.

using Sublime Text 3 to create a file upload class in PHP

I’ll be sharing my robust PHP file upload class on Github soon, at which point I’ll link to it here.

David Schrimpf, Web Developer

David

I have been a full-time professional web developer for over 12 years. This is my blog where I write about topics that interest me, mostly relating to computers and software and the internet.

Check out my portfolio for some examples of my web development & and app development work.

Elsewhere

GitHub