Jump to content

Recommended Posts

for school I had to make a site about poems,

all works fine,

but only one problem

they want to be able to add images, music, video's etc.

Now I've to do everything manual.

Now I want to let the users upload it themself.

 

I'm thinking of making a new table

user_id(tinyint)  poem_id(tinyint)  type(enum)

 

should I make an upload system,

or should I say they have to store it somewhere else, like imageshack.us and give the link?

 

I can trust the users, beause only people I know and are in my class can 'join' the site.

Most likely you want to create a directory for each and every user to store their media, however when doing so you will not only allow them but also every visitor that stumbles upon it can sniff those directories. You can use .htaccess, but do you possess the skill to write the required complex code? and is it worth the effort? Personally I would create the upload system using PHP as it allows the fine grained control I want and it keeps it simple.

 

P.S. type(enum)

 

Just some advice, don't use an enum but use a varchar instead. Create constants that holds certain values and can be used throughout your application:

 

define('MEDIA_TYPE_IMAGE', 'image');
define('MEDIA_TYPE_VIDEO', 'video');
define('MEDIA_TYPE_MUSIC', 'music');

 

INSERT INTO table VALUES ($users_id, $poems_id, MEDIA_TYPE_*)

 

switch ($type) {
    case MEDIA_TYPE_IMAGE:
        //logic
        break;
    case MEDIA_TYPE_VIDEO:
        //logic
        break;
    case MEDIA_TYPE_MUSIC:
        //logic
        break;
}

 

This way you can avoid typo's (and decrease bugs) as an undefined constant throws a notice but is converted to a string ("MEDIA_TYPE_MUSIC") while a typo is valid nonetheless

so I have a table:

 

user_id  poem_id  MEDIA_TYPES_*      name

---1----------1----------image---------example.jpg

---2----------1----------video----------test.avi

 

 

?

 

for the upload system I will just take one from the internet is this good enough?

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.