ARkadaşlar hepinize teşekkürler.Yazdıklarınızı şimdi okuma fırsatı bulabildim.
Aşağıda kodları teker teker yazdım.
Upload edilecek dosyanın seçim ekranının form kodları
<form method="post" enctype="multipart/form-data" action="upload.asp">
<p align="center">
<table border="0" id="table2" cellspacing="0" cellpadding="0" width="876">
<tr>
<td width="20"><img border="0" src="images/kose1.png" width="20" height="20"></td>
<td background="images/orta.png" colspan="5">
<p align="center"><b>
<font color="#FFFFFF" face="Arial Narrow">Yeni Firma Banner'i Ekleme
Ekranı</font></b></td>
<td width="20"><img border="0" src="images/kose2.png" width="20" height="20"></td>
</tr>
<tr>
<td background="images/orta.png" width="20"> </td>
<td background="images/orta.png" width="275">
</td>
<td background="images/orta.png" width="72">
<font color="#FFFFFF" face="Arial Narrow">Banner</font></td>
<td background="images/orta.png" width="8">
<font color="#FFFFFF" face="Arial Narrow">:</font></td>
<td background="images/orta.png" width="465">
<INPUT NAME="BannerLink" SIZE="30" TYPE=file></td>
<td background="images/orta.png" width="16"> </td>
<td background="images/orta.png" width="20"> </td>
</tr>
<tr>
<td background="images/orta.png" width="20"> </td>
<td background="images/orta.png" width="275"> </td>
<td background="images/orta.png" width="72"> </td>
<td background="images/orta.png" width="8"> </td>
<td background="images/orta.png" width="465"> &n bsp; &nbs p; <input type="submit" value="Kaydet"></td>
<td background="images/orta.png" width="16"> </td>
<td background="images/orta.png" width="20"> </td>
</tr>
<tr>
<td width="20"><img border="0" src="images/kose3.png" width="20" height="20"></td>
<td background="images/orta.png" width="275"> </td>
<td background="images/orta.png" width="72"> </td>
<td background="images/orta.png" width="8"> </td>
<td background="images/orta.png" width="465"> </td>
<td background="images/orta.png" width="16"> </td>
<td width="20"><img border="0" src="images/kose4.png" width="20" height="20"></td>
</tr>
</table>
Tuşa basıldığında yönlendirdiği upload.asp dosyasının kodları;
<!--#include file="CBUpload.asp" --><%
dim Upload, File, Item, iTimer
iTimer = Timer()
Server.ScriptTimeout = 36000
set Upload = new cls_CBUpload
Response.Write("File count: " & Upload.Files.Count)
Response.Write("<br /><br />")
for each File in Upload.Files
set File = Upload.Files(File)
Response.Write(File.Name & "<br />")
Response.Write(File.Size & " bytes<br />")
Response.Write(File.FormName & "<br />")
Response.Write(File.ContentType & "<br />")
if(File.SaveToFile(Server.Mappath("banners/" & File.Name))) then
Response.Write("Saved file...<br />")
end if
Response.Write("<br />")
next
for each Item in Upload.Form
Response.Write(Item & ": " & Upload.Form(Item) & "<br />")
next
set Upload = nothing
Response.Write(Timer - iTimer)
%>
upload.asp dosyasına include edilen dosyanın kodları;
<%
'************************************************* ****
'************************************************* ****
'** **
'** CrazyBeavers Upload Class v 1.2 **
'** **
'** If you wish to use this piece of code in **
'** your own applications you have to let this **
'** statement remain in it's current state. If **
'** you plan to redistribute your application **
'** you will have to have inform the users **
'** that you are using CB Upload Class and that **
'** they can find more information about it on **
'** CrazyBeaver Softwares homepage located at the **
'** URL below: **
'** **
'**
http://www.crazybeavers.se/ **
'** **
'** Large parts of this code is based on code by **
'** Gez Lemon of Juicy Stuido. It has been **
'** and partially rewritten and enhanced by **
'** CrazyBeaver Software along with it's new class **
'** interface. For more information on Juicy **
'** Studio please see the URL below: **
'** **
'**
http://www.juicystudio.com/ **
'** **
'** / Karl-johan Sjögren **
'**
http://www.crazybeavers.se/ **
'** © 2005 CrazyBeaver Software **
'** **
'************************************************* ****
'************************************************* ****
class cls_CBUpload_File
public Name
public Data
public ContentType
public FormName
public function Size
Size = len(Data)
end function
public function SaveToFile(sFilename)
dim sBrowser
dim oFSO, oSaveFile
dim iStartPos
set oFSO = server.createObject("Scripting.FileSystemObject")
SaveToFile = true
on error resume next
set oSaveFile = oFSO.CreateTextFile(sFilename, true)
oSaveFile.Write(Data)
oSaveFile.Close
if(Err <> 0) then
SaveToFile = false
end if
on error goto 0
set oSaveFile = Nothing
set oFSO = Nothing
end function
end class
class cls_CBUpload
public Form
public Files
public Error
sub parseFormData(byref aData)
Response.Write(Timer - iTimer & "<br />")
dim iCounter, iEndMarker
dim sFieldInfo, sFieldValue
dim oFile
for iCounter = 0 to UBound(aData)
iEndMarker = instr(aData(iCounter), vbCrLf & vbCrLf)
if iEndMarker > 0 then
sFieldInfo = mid(aData(iCounter), 3, iEndMarker - 3)
sFieldValue = mid(aData(iCounter), iEndMarker + 4, len(aData(iCounter)) - iEndMarker - 7)
if(instr(sFieldInfo, "filename=") > 0) then
if(len(getFileName(sFieldInfo)) > 0) then
set oFile = new cls_CBUpload_File
oFile.Name = getFileName(sFieldInfo)
oFile.FormName = getFieldName(sFieldInfo)
oFile.Data = sFieldValue
oFile.ContentType = getContentType(sFieldInfo)
call Files.Add(getFieldName(sFieldInfo), oFile)
set oFile = nothing
end if
else
call Form.Add(getFieldName(sFieldInfo), sFieldValue)
end if
end if
next
end sub
function getFieldName(sData)
dim iStartPos, iEndPos, sQuote
if(sData = "") then
getFieldName = ""
exit function
end if
sQuote = chr(34)
iStartPos = instr(sData, "name=")
iEndPos = instr(iStartPos + 6, sData, sQuote & ";")
if iEndPos = 0 then
iEndPos = instr(iStartPos + 6, sData, sQuote)
end if
getFieldName = mid(sData, iStartPos + 6, iEndPos - (iStartPos + 6))
end function
function getContentType(byval sData)
dim iStartPos, iEndPos
if(sData = "") then
getContentType = ""
exit function
end if
iStartPos = instr(sData, "Content-Type: ")
iEndPos = len(sData)
getContentType = mid(sData, iStartPos + 14, iEndPos)
end function
function getFileName(byval sData)
dim sBrowser
dim iStartPos, iEndPos, sQuote
if(sData = "") then
getFieldName = ""
exit function
end if
sQuote = Chr(34)
iStartPos = instr(sData, "filename=")
iEndPos = instr(iStartPos + 10, sData, sQuote & ";")
if iEndPos = 0 then
iEndPos = instr(iStartPos + 10, sData, sQuote)
end if
sData = mid(sData, iStartPos + 10, iEndPos - (iStartPos + 10))
sBrowser = UCase(Request.ServerVariables("HTTP_USER_AGENT"))
if(instr(sBrowser, "WIN") > 0) then
iStartPos = instrrev(sData, "\")
sData = mid(sData, iStartPos + 1)
else
iStartPos = instrrev(sData, "/")
sData = mid(sData, iStartPos + 1)
end if
getFileName = sData
end function
function parseRequest()
const adLongVarChar = 201
dim oRS
dim iBytesRead, iBlockSize, iTotalBytes
iTotalBytes = Request.TotalBytes
iBlockSize = 16384
iBytesRead = 0
set oRS = CreateObject("ADODB.Recordset")
oRS.Fields.Append "BinaryField", adLongVarChar, iTotalBytes
oRS.Open
oRS.AddNew
do while(iBytesRead < iTotalBytes)
if(iBytesRead + iBlockSize < iTotalBytes) then
oRS("BinaryField").AppendChunk Request.BinaryRead(iBlockSize)
iBytesRead = iBytesRead + iBlockSize
else
oRS("BinaryField").AppendChunk Request.BinaryRead(iTotalBytes - iBytesRead)
iBytesRead = iTotalBytes
end if
loop
oRS.Update
parseRequest = oRS.Fields("BinaryField").Value
oRS.Close
set oRS = nothing
end function
sub Class_Initialize
dim sData, sContentType, sBoundary
dim iEndPos
dim aData
sContentType = Request.ServerVariables("HTTP_CONTENT_TYPE")
if InStr(sContentType, "multipart/form-data") > 0 then
sData = parseRequest
iEndPos = InStrRev(sContentType, "=")
sBoundary = Trim(Right(sContentType, Len(sContentType) - iEndPos))
aData = Split(sData, sBoundary)
set Form = CreateObject("Scripting.Dictionary")
set Files = CreateObject("Scripting.Dictionary")
call parseFormData(aData)
else
Error = "Incorrect encoding type"
end if
end sub
sub Class_Terminate
set Form = nothing
set Files = nothing
end sub
end class
%>
Bu kodlarım sadece dosyayı servere atmama yardımcı oluyor.Ama ben servre atarken yada attıkta sonra dbye linkini ve bilgilerini kayıt etmek istiyorum.
Yardımlarınız için şimdiden teşekkürler.