File Upload / Download handler in PHP and SQL #buildinpublic

Most applications enable users to import / export data (upload / download files).

Since I’ve already established a connection between PHP and the SQL database, I knew that it would 100% be possible to store a .pdf file in there… I just had to figure out how.

Enabling users to upload .pdf or .doc files in PHP and view those files later

In the EspressoHire app I’m building, I needed a way for candidates to upload their resume when they apply for a job. Conversely, I needed recruiters to be able to view / download the candidates resume later.

In order to achieve this, I needed to write software that would sit between the user-facing application and the database, communicating the user-input over to the database.

Unlike basic variable assignments in PHP, you can’t just assign a resume file to a variable and store it in your database. It’s a bit more complex than that.

This took days of work. By far, the most difficult features I’ve built so far. I’d say that getting the uploader working was by far more difficult than getting the downloader working.

Once I figured out how to handle file uploads, handling file downloads was done via a similar method, and I built up the knowledge base to know how to do it.

Pre-built file upload / download code blocks in PHP

Now that I’ve created the software programs to handle file uploads / downloads, I’ll be able to re-purpose these code blocks across any other features and apps that I build.

There are essentially two pre-built components that anyone could re-use out of the box:

  • File uploader
  • File downloader

Since this took several hours of development work to build, why re-invent the wheel? Others should be able to use this too.

Would other developers find this valuable if I shared the programs with them?

Only 1 feature left to build

For what it’s worth, file upload / download handling is the second to last feature that I needed to build before I can confidently say I have an MVP.

The LAST feature I’m building over today / tomorrow (or however many days it takes me!) is user management and role-based-access control.

Essentially making sure that only authorized users can log into the application, view candidate data, and post jobs.

#buildinpublic series – read my first post here.


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *