Hello,
I have a simple image multi uploader that uploads images on the folder correctly but i don't know how to get the image names and insert them in the db. The uploader is part of a complex form for adding an article informations (id, name, permanenturl, section, etc) that works correctly.
Image fields in db has names as follows: img1 img2 img3 img4 im5, a field for each image (since i thought that this is the best way to add the images on the article).
The upload sections looks like this:
<?php
/**
* Smart Image Uploader by @cafewebmaster.com
* Free for private use
* Please support us with donations or backlink
*/
$upload_image_limit = 5; // How many images you want to upload at once?
$upload_dir = "/var/www/tour/te-ngarkuara/oferta/"; // default script location, use relative or absolute path
################################# UPLOAD IMAGES
foreach($_FILES as $k => $v){
$img_type = "";
### $htmo .= "$k => $v<hr />"; ### print_r($_FILES);
if( !$_FILES[$k]['error'] && preg_match("#^image/#i", $_FILES[$k]['type']) && $_FILES[$k]['size'] < 1000000){
$img_type = ($_FILES[$k]['type'] == "image/jpeg") ? ".jpg" : $img_type ;
$img_type = ($_FILES[$k]['type'] == "image/gif") ? ".gif" : $img_type ;
$img_type = ($_FILES[$k]['type'] == "image/png") ? ".png" : $img_type ;
$data = (date("jnHi")); // Merr daten dhe oren ne momentin e shtimit te fotografise
$img_rname = $data."-".$_FILES[$k]['name']; // shton daten dhe oren perpara emrit te fotografise per te krijuar emer unik
$img_rname = str_replace(" ","-",$img_rname); // Heq hapesirat dhe i zevendeso me -
$img_path = $upload_dir.$img_rname;
copy( $_FILES[$k]['tmp_name'], $img_path );
chmod("$img_path",0777);
$feedback .= "Image and thumbnail created $img_rname<br />";
}
}
############################### HTML FORM
while($i++ < $upload_image_limit){
$form_img .= '<label>Image '.$i.': </label> <input type="file" name="uplimg'.$i.'"><br />';
}
$htmo .= '
<p>'.$feedback.'</p>
<form method="post" enctype="multipart/form-data">
'.$form_img.' <br />
<input type="submit" value="Upload Images!" style="margin-left: 50px;" />
</form>
';
echo $htmo;
Can anyone help me on this, please?
Thank you in advance!