Hello there!
I am looking around for a way to upload image on server (via browse button) and in the database insert only the path of that image.
What i have just now is the form, the form processor and the database but i don;t know how to do that.
add.php
<?php
session_start();
if(!isset($_SESSION['loggedin'])) {
header('Location: '.$domain.'index.php?error=1');
exit();
}
define("NGA_ADMIN", true);
?>
<form id="shtoprodukte" action="modulet/produktet/p.shtoprodukte.php" method="post" name="shtoprodukte">
<table width="740" border="0" cellspacing="2" cellpadding="0">
<tr><td width = "150"><div align="right"><label for="katid">Kategoria</label></div></td>
<td><select id="katid" name="katid" size="1">
<?php
include 'D:/Program Files/VertrigoServ/www/joni/admini/includet/variabla.php';
include (BPATH_ADM . 'includet/dbconfig.php');
$query="SELECT * FROM p_kategori ";
$result=mysql_query($query);
$num = mysql_num_rows ($result);
mysql_close();
?>
<?php
if ($num > 0 ) {
$i=0;
while ($i < $num) {
$katemri = mysql_result($result,$i,"katemri");
$katpermalink = mysql_result($result,$i,"katpermalink");
$kataktiv = mysql_result($result,$i,"kataktiv");
$id = mysql_result($result,$i,"id");
?>
<option value="<?php echo $id; ?>"><?php echo $katemri; ?></option>
<?php
++$i; } }
?>
</select></td></tr>
<tr><td width = "50"><div align="right"><label for="prodemri">Emri</label></div></td>
<td><input id="prodemri" name="prodemri" type="text" size="25" value="" maxlength="255"></td></tr>
<tr><td width = "50"><div align="right"><label for="prodinfo">Info</label></div></td>
<td><textarea id="prodinfo" name="prodinfo"></textarea>
<script type="text/javascript">
CKEDITOR.replace( 'prodinfo',
{
filebrowserBrowseUrl : '/joni/admini/includet/ckfinder/ckfinder.html',
filebrowserImageBrowseUrl : '/joni/admini/includet/ckfinder/ckfinder.html?Type=Images',
filebrowserFlashBrowseUrl : '/joni/admini/includet/ckfinder/ckfinder.html?Type=Flash',
filebrowserUploadUrl : '/joni/admini/includet/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files',
filebrowserImageUploadUrl : '/joni/admini/includet/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images',
filebrowserFlashUploadUrl : '/joni/admini/includet/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Flash'
});
</script>
</td></tr>
<tr><td width = "50"><div align="right"><label for="prodimg">Fotografia</label></div></td>
<td><input id="prodimg" name="prodimg" type="text" size="25" value="" maxlength="255"></td></tr>
<tr><td width = "50"><div align="right"><label for="prodaktiv">Aktive</label></div></td>
<td><input id="prodaktiv" name="prodaktiv" type="checkbox" value="Y"></td></tr>
<tr><td width="45"></td><td>
<input type="submit" name="shtoje" value="Shtoje"> </td>
</tr></table></form>
p.add.php
<?php
ob_start();
session_start();
if(!isset($_SESSION['loggedin'])) {
header('Location: '.$domain.'index.php?error=1');
exit();
}
define("NGA_ADMIN", true);
?>
<?php
include 'D:/Program Files/VertrigoServ/www/joni/admini/includet/variabla.php';
include (BPATH_ADM . 'includet/dbconfig.php');
$prodemri = $_POST['prodemri'];
$prodinfo = $_POST['prodinfo'];
$prodimg = $_POST['prodimg'];
$katid = $_POST['katid'];
$prodaktiv = $_POST['prodaktiv'];
$query = "INSERT INTO p_produkte (id, katid, prodemri, prodinfo, prodimg, prodaktiv)
VALUES ('', '$katid ', '$prodemri', '$prodinfo', '$prodimg', '$prodaktiv')";
$results = mysql_query($query);
if ($results)
{
header( 'refresh: 0; url= '.$admurl.'admin.php?sukses=1' );
}
mysql_close();
ob_flush();
?>
p_produkte table (products)
Field Type
id int(6)
katid int(255)
prodemri varchar(255)
prodimg varchar(255)
prodinfo text
prodaktiv enum('N', 'Y')
p_kategori table (category)
Field Type
id int(6)
katemri varchar(255)
katpermalink varchar(255)
kataktiv enum('N', 'Y')
...where prodimg is the label where should be the browse button and where should be inserted the path of the image on the database table named the same (prodimg).
Hope that someone can help me. Thanks in advance!