As an integral part of our website we needed to be able to login and upload an image to it. We found various resources online (e.g. Stack overflow ) where there were many explanations on how to go about this. We found that along with being able to simply upload an image, we also needed to make checks on the image to see if its was actually an image file, be able to limit the size of file and finally not allow duplicates in the target directory.
After working hard to get all of this working we ran into one major problem. There was a problem with our permissions. After going in and changing them to 776 (as many forums suggested) we still could not get the uploader to work.
It turns out that Dakar did not allow files to be written into directories. This is where we decided to make the switch to my own hosting. On my domain we could change the permissions to allow the upload to work.
We Built a simple upload form in HTML and linked it to our upload script and had it working fairly soon after on my hosting. The script now checks for Real image, duplicates, file size limit and only allow certain file formats before uploading.
It makes all of these checks and finally redirects back to the home page after uploading. Getting the redirect to work was difficult as it is a custom function we learned from Kyle in one of our PHP workshops. To make it work in the end we included the function in the header that is present on every page, therefore the function would work anywhere on the app.