Hey guys,
I’m just wondering the best way to approach this.
On my blog site, I have a place where I can write a blog post. Along with that I can add one image to a database.
I want to add 5 images instead, so I can display these images in association with the given blog post at a later stage.
So it works fine with 1 image and running the query once.
I tried putting the query in a for loop and looping it 5 times, and looking in the $_FILES array for the right values.
However i’m not sure if this was done correctly.
[code=php]
for ($i = 5; $i <= 5; $i += 1)
{
$imgQuery = sprintf(“insert into journal_img
set
journal_id = ‘%s’,
img_name = ‘%s’,
img_size = ‘%s’,
img_type = ‘%s’,
img_path = ‘%s’
“,
mysql_real_escape_string($fid),
mysql_real_escape_string($fileName),
mysql_real_escape_string($fileSize),
mysql_real_escape_string($fileType),
mysql_real_escape_string($filePath));
}
The variable values have been extracted like this
[code=php]
$fileName = $_FILES[‘userfile’][‘name’];
$tmpName = $_FILES[‘userfile’][‘tmp_name’];
$fileSize = $_FILES[‘userfile’][‘size’];
$fileType = $_FILES[‘userfile’][‘type’];
Shooting from the hip here, I guess I need to access value 0 to 4 in the $_FILES array and increment the query values by 1 on the $
Anyone who can help with this would be brilliant.
Thanks in advance
Alistair?