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? :-\

 

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.