Jump to content

Uploading and displaying images on site - the blueprint


V

Recommended Posts

Today I'll attempt to make a script that I can use to upload images to certain posts and display them. (should be fun  :D ) I'll have a thumbnail version and a larger size version. I looked online for some tutorials but couldn't find anything good, mostly how to upload to MYSQL which I heard is a terrible idea. So I'd like to share my own idea and would greatly appreciate any kind of feedback or guidance :) I'm not sure if I'm approaching this right..

 

I already integrated a script that creates thumbnails. It puts the full sized images in a img/fullsize folder and the thumbnails in a img/thumbs folder.

 

So I'm planning to echo the path to the thumnbail and fullsize images and insert the paths into the DB. An "images" table will have an unique ID, image_path, post_id to identify the post an image was uploaded to, and a size, for example thumb or large.

 

So when I upload an image I'll use something like INSERT $thumb, $large, $post_id INTO images=.. bla bla bla

 

$thumb and $large are variables of the image paths. I suppose I'll insert to DB them via ajax, on submit.

 

and to display thumbnails for example I'll use  SELECT * FROM images WHERE post_id='$post_id' AND type=thumb.. bla bla bla

 

then echo

 

<img src="<?php echo $thumb_file_path; ?>" alt="" />

 

same for large images

 

Is it ok? :-\

 

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.