Sitemizin kullanıcılarının image dosyalarını yükledikleri ve linkini aldıkları bir uygulamamız var ancak veritabanı kullanmıyor. dosyaları klasöre yukledikten sonra direkt ve forum linklerini veriyor. bu hali ile işimizi görse de yüklenen resimleri görüntüleyecek bir sayfa yaptığımız zaman klasördeki tüm dosyaları yüklüyor ve bu hali ile klasör listeleme, sayfalama vb. işlemler oldukça zor oluyor.
Image dosyasını yükledikten sonra verdiği linki veritabanına yazdırmak için ne yapmam lazım? db deki tabloda 2 satır var, id ve dosyayolu.
<?php
header("Content-Type: text/html; charset=iso-8859-9");
require('ekler/fonksiyonlarim.php');
require('ekler/ayarlarim.php');
?>
<html>
<head>
<link rel="shortcut icon" href="http://localhost/favicon.ico" />
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-37822979-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<script type="text/javascript">var switchTo5x=true;</script>
<script type="text/javascript" src="http://w.sharethis.com/button/buttons.js"></script>
<script type="text/javascript">stLight.options({publisher: "0aecccbd-0a79-48dc-9f53-c5507c1745d5"});</script>
<script type="text/javascript">stLight.options({publisher: "0aecccbd-0a79-48dc-9f53-c5507c1745d5"});</script>
<meta http-equiv=Content-Type content="text/html; charset=iso-8859-9">
<meta http-equiv=content-type content="text-html; charset=windows-1254">
<title>Resmim Image Hosting</title>
<link href="images/stil.css" rel="stylesheet" type="text/css">
<script type="text/javascript">
function highlight(field) {
field.focus();
field.select();
}
var maxWidth=100;
var maxHeight=100;
var fileTypes=["jpg","jpeg","bmp","gif","png","swf","flw"];
var outImage="previewField";
var defaultPic="spacer.gif";
/***** DO NOT EDIT BELOW *****/
function preview(what){
var source=what.value;
var ext=source.substring(source.lastIndexOf(".")+1,source.length).toLowerCase();
for (var i=0; i<fileTypes.length; i++) if (fileTypes[i]==ext) break;
globalPic=new Image();
if (i<fileTypes.length) globalPic.src=source;
else {
globalPic.src=defaultPic;
alert("Yabancı Bir Cisim Yaklaşıyor!\n\nİzin verilen dosyalar:\n\n"+fileTypes.join(", "));
}
setTimeout("applyChanges()",200);
}
var globalPic;
function applyChanges(){
var field=document.getElementById(outImage);
var x=parseInt(globalPic.width);
var y=parseInt(globalPic.height);
if (x>maxWidth) {
y*=maxWidth/x;
x=maxWidth;
}
if (y>maxHeight) {
x*=maxHeight/y;
y=maxHeight;
}
field.style.display=(x<1 || y<1)?"none":"";
field.src=globalPic.src;
field.width=x;
field.height=y;
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}
</script>
<?php
if($_POST){
require_once ('ekler/posttan.php');
}
?>
<style type="text/css">
<!--
body {
background-image: url(images/4.jpg);
background-repeat: no-repeat;
}
a:link {
color: #FFFFFF;
text-decoration: none;
}
a:visited {
text-decoration: none;
color: #FFFFFF;
}
a:hover {
text-decoration: underline;
color: #FFFFFF;
}
a:active {
text-decoration: none;
color: #FFFFFF;
border: thin solid #900;
font-size: 10px;
font-weight: bold;
}
-->
</style>
</head>
<body>
<center>
<form enctype="multipart/form-data" method=post>
<table width=513 border=0 align=center>
<tr>
<td height="50" colspan="2" align=center><a href="index.php"><img src="images/image.fw.png" width="360" height="59" longdesc="index.php" align="middle"><img src="images/logo.png" width="64" height="64" longdesc="index.php" align="middle"></a></td>
</tr>
<tr>
<td height="20" colspan="2" align=center> </td>
</tr>
<tr>
<td height="20" colspan="2" align=center> </td>
</tr>
<tr>
<td height="20" colspan="2" align=center> </td>
</tr>
<tr>
<td height="10" colspan="2" align=center><span class="uyari"><strong class="uyari2" style="font-size: 10px">jpg, jpeg, bmp, gif, png, swf, flv. | MAXİMUM Dosya Boyutu :
<?php $maximum_mb = $azami / 1024 / 1024;
echo number_format($maximum_mb, 2, ",", ".");?>
MB </strong></span></td>
</tr>
<tr>
<td colspan="2" align=center><table border="1" align="center" cellpadding="1" cellspacing="1">
<tr id="tabela">
<td width="498" height="39" style="text-align: center"><input name=resim type=file class="file" onChange="preview(this)" size="50">
<input name=gonder type=submit class="file" value="Gönder"></td>
</tr>
</table></td>
</tr>
<tr>
<td height="5" colspan="2" align=center> </td>
</tr>
<tr>
<td colspan="2" align=center><table border="0" align="center" cellpadding="3" cellspacing="0">
<tr>
<td width="503" height="164"><?php
if($_POST){
if ($boyut >= $azami){
uyari('Dosya Haddinden Fazla Büyük!');
}
if ($resim != "" && $boyut <= $azami){
$uzanti_izinlimi = ptIzinlimi($uzanti);
if ($uzanti_izinlimi == 'evet'){ // Yüklenmesini istediğimiz dosya türlerini burada belirliyoruz...
move_uploaded_file ($_FILES['resim']['tmp_name'], $klasor.$yeniresim) or die ('Hatalı İşlem Dosya kopyalanamıyor'); //Dosyamızı klasörümüze taşıyoruz.
?>
<table width="504" border=0 align=center cellpadding="0" cellspacing="0" class="uyari2">
<tr>
<td width="107" align=right bgcolor="#CCCCCC" style="text-align: right"><b> Direkt Link</b></td>
<td width="10" align=right bgcolor="#CCCCCC" style="font-size: 12px; text-align: center;"><span style="text-align: center"><b></b></span><b>:</b></td>
<td width="387" align=left style="text-align: left"><input name="text" type=text class="search" onClick='highlight(this);' value="<?=$link?>"></td>
</tr>
<tr>
<td align=right bgcolor="#CCCCCC" style="text-align: right"><b> Thumbnail Link</b></td>
<td align=right bgcolor="#CCCCCC" style="font-size: 12px; text-align: center;"><b>:</b></td>
<td align=left style="text-align: left"><input class="search" onClick='highlight(this);' type=text value="<a href="<?=$link?>"><img src="<?=$link?>" width="200" border="0"></a>"></td>
</tr>
<tr>
<td align=right bgcolor="#CCCCCC" style="text-align: right"><b> Forum Linki 1</b></td>
<td align=right bgcolor="#CCCCCC" style="font-size: 12px; text-align: center;"><b>:</b></td>
<td align=left style="text-align: left"><input class="search" onClick='highlight(this);' type=text value="[IMG]<?=$link?>[/IMG]"></td>
</tr>
<tr>
<td align=right bgcolor="#CCCCCC" style="text-align: right"><b> Forum Linki 2</b></td>
<td align=right bgcolor="#CCCCCC" style="font-size: 12px; text-align: center;"><b>:</b></td>
<td align=left style="text-align: left"><input class="search" onClick='highlight(this);' type=text value="[img=<?=$link?>][/img]"></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
<tr>
<td height="200" colspan="2" align=center><p><b><a href="<?=$link?>"> <img src="<?=$link?>" alt="<?=$link?>" width="150" border=0></a><br>
<strong class="footer"><b>Resmi normal boyutta görmek için üzerine tıklayın...</b></strong><br>
<span style="font-weight: bold; font-size: 9px;">
Resim Boyutu =
<?=$boyutkb?>
</span></b> <b><span style="font-weight: bold; font-size: 9px;">
<?php
}
if ($resimismi == ""){
uyari('Dosya Seçin Lütfen!');
}
if ((!$resimismi == "")&&($uzanti_izinlimi == 'hayir')){
uyari('Hatalı Dosya Formatı');
}
}
}
if(!$_POST){
uyari('');
}
?>source kodu bu şekildebir de formdan gelen verileri değişkenlere atadığım posttan.php sayfası var
<?php
error_reporting(0);
header("Content-Type: text/html; charset=iso-8859-9");
// formdan gelen bilgileri deðiþkenlere atýyoruz
$resim = $_FILES['resim'];
$resimismi = $_FILES['resim']['name'];
$resimismi2 = ptRU($resimismi);
$resimturu = $_FILES['resim']['type'];
$uzanti = ptUzanti($resimismi2);
$boyut = $_FILES['resim']['size'];
$gonder = $_POST['gonder'];
$kbyecevir = $boyut / 1024;
$boyutkb = number_format($kbyecevir, 2, ',', '.')." Kilobyte" ;
$domain = $_SERVER['SERVER_NAME'];
$rasgele = mt_rand(); // rasgele sayý üretiyoruz.
$yeniresim = $rasgele.".".$uzanti;
$link = 'http://'.$domain.$scriptyolu.'/'.$klasor.$yeniresim;
?>resim yüklendikten sonra $link direkt olarak resmin adresi ve bu değeri db deya yazdırmam için ne yapmam lazım.yardımcı olursanız memnun olurum
saygılar