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?

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.