Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
August 17, 2004, 12:45 pm
rate this thread
pictures and keep them separate and tied to their record in the database.
I want the whole thing automated and I'm just trying to get my arms around
what all is entailed.
Each user will upload about 20 - 100 pictures and each will be related to a
different database record.
I see the process in general as this:
- when the user registers, a picture directory should be automatically
- user creates a record in the database using a form AND uploads a picture
for that record (how is that picture marked as related to that record?)
I'd appreciate any big picture advice AND links to code for any part of this
Any security concerns? How do I handle those?
Re: how to upload pictures and relate them to specific users
relate the picture however you like. you could for instance store the
path/filename in your db-record or - if you have a primary key - just
rename the picture to $primary_key.jpg.
best way in my opinion, cause it saves you having writeable
directories in your site, store the pictures in the db as well (look
let's suppose we uploaded the picture from a form field called 'image'
$image_string = addslashes(file_get_contents($_FILES['image']['tmp_name']));
//convert image into a string, addslashes() to mask special chars that
mess up the query
$type = exif_imagetype($_FILES['bild']['tmp_name']);
//find out the image type (i.e. jpg)
$query = mysql_query("INSERT INTO table SET type = '$typ', image =
now the db contains the image as a string. to get it out and display
$ih = imagecreatefromstring($image_string);
case 1: //gif
case 2: //jpeg
case 3: //png
this little script can be used in html-img-tags just like an image(img
well, directorys where people can just automatically upload files