Geekzone: technology news, blogs, forums
Guest
Welcome Guest.
You haven't logged in yet. If you don't have an account you can register now.




4499 posts

Uber Geek

Trusted

#257464 4-Oct-2019 14:32
Send private message

Kia ora team, just a general question for the developer types out there.

 

We have a little custom calendar 'app' we use to manage our civil teams who aren't, obviously, office-bound with easy PC access. It's HTML (with bootstrap for styling/responsiveness) with a PHP & MySQL back-end. The whole thing is behind a log-in.

 

I'm knocking together a basic web form they can use for near miss reporting so they can just jump on their phones and fill this out. I'd like to include a file upload field so they can take a photo and upload if required. I just wanted to sound off what I plan on doing and see if it's the "right" thing to do....

 

- User submit forms
- PHP to check file type, and if it's actually an image (apparently getimagesize() can be used to do that?)
- If file OK, rename with a unique ID (to avoid conflicting file names) and dump in to a folder in the web directory
- Create a DB entry (probably just do a separate table for them i guess?) with the UID/filename, and other appropriate info to index against the correct 'near miss report'

 

From there a "manager" will just get a notification a new report has been submitted, and they can jump on to a view a list of the reports and export a PDF of the report if required - hence the need to store the image.

 

Does that all sound OK? Anything else I should verify before letting the file to be uploaded to the script?

 

This isn't a "mission critical" type application. It runs on a VM that gets backed up daily, so I'm not overly concerned with security, but also don't want the pain of having to rebuild it just because of some dodgy file upload.


Create new topic
Webhead
2470 posts

Uber Geek

Moderator
Trusted
Lifetime subscriber

  #2329652 4-Oct-2019 14:45
Send private message

You should make sure its not possible to execute PHP and other script languages in the folder you store the images.

 

I would also make sure that its not easy to go through the images, thats to say that you don´t store them as imageID.jpg (thats to say, image01.jpg, image02.jpg etc). If its easy to increase the number and find the attachments that might be a problem in that the images would be easily available for people that shouldn´t see them.

 

 

 

This discussion on Stackoverflow seems a good one on the topic.


BDFL - Memuneh
67118 posts

Uber Geek

Administrator
Trusted
Geekzone
Lifetime subscriber

  #2329667 4-Oct-2019 15:34
Send private message
 
 
 
 




4499 posts

Uber Geek

Trusted

  #2329686 4-Oct-2019 16:49
Send private message

That Stackoverflow link is excellent!

 

Looks like I had the right idea. Didn't think about using htaccess to stop PHP running in that folder - great plan. Now also understand how getimagesize can work too.


Create new topic



Twitter and LinkedIn »



Follow us to receive Twitter updates when new discussions are posted in our forums:



Follow us to receive Twitter updates when news items and blogs are posted in our frontpage:



Follow us to receive Twitter updates when tech item prices are listed in our price comparison site:





News »

OPPO Find X2 Lite brings flagship features to mid-range 5G smartphone
Posted 29-May-2020 12:52


Sony introduces the digital camera ZV-1 for content creators
Posted 27-May-2020 12:47


Samsung Announces 2020 QLED TV Range
Posted 20-May-2020 16:29


D-Link A/NZ launches AI-Powered body temperature measuring system
Posted 20-May-2020 16:22


NortonLifeLock Online Banking Protection now available for New Zealand banks
Posted 20-May-2020 16:14


SD Express delivers new gigabyte speeds for SD memory cards
Posted 20-May-2020 15:00


D-Link A/NZ launches Nuclias cloud managed network solution hosted in Australia
Posted 11-May-2020 17:53


Logitech introduces new video streaming solution for home studios
Posted 11-May-2020 17:48


Next generation Volvo cars to be powered by Luminar LiDAR technology
Posted 7-May-2020 13:56


D-Link A/NZ launches Wi-Fi Certified EasyMesh system
Posted 7-May-2020 13:51


Spark teams up with Microsoft to bring Xbox All Access to New Zealand
Posted 7-May-2020 13:01


Microsoft plans to establish its first datacenter region in New Zealand
Posted 6-May-2020 11:35


Genesis School-gen has joined forces with Mind Lab Kids
Posted 1-May-2020 12:53


Malwarebytes expands into privacy with fast, frictionless VPN
Posted 30-Apr-2020 16:06


Kordia to donate TV airtime on Channel 200 to community groups
Posted 30-Apr-2020 16:00



Geekzone Live »

Try automatic live updates from Geekzone directly in your browser, without refreshing the page, with Geekzone Live now.


Support Geekzone »

Our community of supporters help make Geekzone possible. Click the button below to join them.

Support Geezone on PressPatron



Are you subscribed to our RSS feed? You can download the latest headlines and summaries from our stories directly to your computer or smartphone by using a feed reader.

Alternatively, you can receive a daily email with Geekzone updates.