Jump to content

Is this a good design? Image upload / deletion in php


arbitrageur

Recommended Posts

I'm building a site similiar to a web forum.

 

The code is all done, this is how it works:

 

CREATING POST:

------------------------

In PHP:
Create Post -> Upload Images

-> Remake Images (For security)

-> Create Thumbnails (saved in uploads folder with unique name)

 

With DATABASE:

I have a table called "images" which tracks user uploaded images:

uploaded_by_username (stores who posted it)

image_status (tracking whether user aborted upload)

thumbnail_confirm (tracking whether thumbnail generated successfully)

post_association (tracking the post that the images go to)

image_name (the image filename in uploads filefolder)

time (unix time-stamp of upload tracking for admin purposes)

 

DELETING POST:

------------------------

In PHP:

Move all images into a "deleted_images" folder ( I'm afraid to use "unlink")

 

With DATABASE:

Delete all associated images from images table ( Is this risky? Should I use a second table and transfer the images? )

 

 

Anyhow, feedback appreciated in regards to how I designed this. Is this acceptable for the industry?

 

1. Depends how you generate the unique name. Should be guaranteed to be unique, not something almost unique like random numbers.

2. I wouldn't bother tracking aborted uploads or whether you were able to generate the thumbnail. If there's a problem then abort the process.

3. Don't delete stuff. Leave the image in the folder and use a column in the table to indicate live/deleted status (you could repurpose "image_status" for that).

 

A more detailed explanation, like the actual code, database schema, and queries, can get you more detailed answers.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.