Faqa newimg.php
Afishon formen per ngarkimin e imazhit
<?php
require_once("start.php");
require_once("db.php");
//kontroll nese eshte id me kuptim
?>
<html>
<head>
<title>Ngarko imazh</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<form name="myform" method='post' enctype='multipart/form-data' action="newimg1.php">
<table width="100%" border="0" class="t12" cellpadding="10" >
<tr>
<td> </td>
</tr>
<tr>
<td>Title :
<input type="text" name="title" size="70" class="t12"> </td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td height="15" align="right" class="t12or"> <div id="info1"></div></td>
</tr>
<tr>
<td valign="top"> <table width="100%" border="1">
<tr>
<td width="62%">Description<br> <textarea class="t12lh24" cols="60" rows="10" name="description"></textarea></td>
<td valign="top"> Upload the file<br> <input type="file" name="myfiles[]"
onChange="document.getElementById('info1').innerHTML = this.value.substr(this.value.lastIndexOf('\\')+1,this.value.length-this.value.lastIndexOf('\\')); myform.title.value=this.value;" class="t12" >
<br> </td>
</tr>
</table></td>
<tr>
<td valign="top" align="center"><input name="submit" type="submit" value="Save" class="t12r">
</td>
</tr>
</table>
</form>
</body>
</html>
Faqa newimg1.php
Ruan imazhin e upload
<?php
require_once("start.php");
require_once("db.php");
//title
if (!isset($_REQUEST["title"]))
{
exit("title??");
}
$title=$_REQUEST["title"];
//content
if (!isset($_REQUEST["description"]))
{
exit("description??");
}
$description=$_REQUEST["description"];
//ngarkojme dokumentat
$numoffile = 1;
// Fix path of your file to be uploaded, don't forget to CHMOD 777 to this folder
$file_dir = "..//images//";
$j=0;
if ($_POST) {
for ($i=0;$i<$numoffile;$i++) {
if (trim($_FILES['myfiles']['name'][$i])!="") {
$newfile = $file_dir.$_FILES['myfiles']['name'][$i];
move_uploaded_file($_FILES['myfiles']['tmp_name'][$i], $newfile);
$j++;
}
}
}
//fund ngarkimi i dokumentave
$f1=$_FILES['myfiles']['name'][0];
/*
$f2=$_FILES['myfiles']['name'][1];
$f3=$_FILES['myfiles']['name'][2];
*/
$active=1; //artikulli eshte aktiv si default
$sql="
insert into images(title,path,description)
values ('".$title."','".$f1."','".$description."')";
mysql_query($sql)
or die(mysql_error());
?>