Binary Dosya Yükleme ADODB.Recordset Set fso CreateObject(Scripting.FileSystemObject Hakkında;
<form ENCTYPE=”multipart/form-data” ACTION=”yukleme2.asp?tur=<%=RS2(”tur”)%>&yuklenecek_id=<%=g_id%>” METHOD=”post” target=”_self” >
<input NAME=”File2” class=”resimyukleme” SIZE=”30” TYPE=”file”>
<input type=”submit” value=” Yükle ” class=”resimyuklebuton” >
</form>
ForWriting = 2
adLongVarChar = 201
lngNumberUploaded = 0
noBytes = Request.TotalBytes
binData = Request.BinaryRead (noBytes)
Set RST = CreateObject(”ADODB.Recordset”)
LenBinary = LenB(binData)
if LenBinary > 0 Then
RST.Fields.Append ”myBinary”, adLongVarChar, LenBinary
RST.Open
RST.AddNew
RST(”myBinary”).AppendChunk BinData
RST.Update
strDataWhole = RST(”myBinary”)
End if
strBoundry = Request.ServerVariables (”HTTP_CONTENT_TYPE”)
lngBoundryPos = instr(1, strBoundry, ”boundary=”) + 8
strBoundry = ”--” & right(strBoundry, len(strBoundry) - lngBoundryPos)
lngCurrentBegin = instr(1, strDataWhole, strBoundry)
lngCurrentEnd = instr(lngCurrentBegin + 1, strDataWhole, strBoundry) - 1
Do While lngCurrentEnd > 0
strData = mid(strDataWhole, lngCurrentBegin, lngCurrentEnd - lngCurrentBegin)
strDataWhole = replace(strDataWhole, strData,””)
lngBeginFileName = instr(1, strdata, ”filename=”) + 10
lngEndFileName = instr(lngBeginFileName, strData, chr(34))
if lngBeginFileName = lngEndFileName and lngNumberUploaded = 0 Then
”Resim boş yükleme Yapılırsa Buraya Yönlendir
Response.Redirect ”dosya_ekle.asp?page=resim_ekle&haber_islemi=ekle&er=1&id=”&yuklenecek_id
End if
if lngBeginFileName <> lngEndFileName Then
strFilename = mid(strData, lngBeginFileName, lngEndFileName - lngBeginFileName)
tmpLng = instr(1, strFilename, ””)
Do While tmpLng > 0
PrevPos = tmpLng
tmpLng = instr(PrevPos + 1, strFilename,””)
Loop
FileName = right(strFilename, len(strFileName) - PrevPos)
lngCT = instr(1,strData, ”Content-Type:”)
if lngCT > 0 Then
lngBeginPos = instr(lngCT, strData, chr(13) & chr(10)) + 4
Else
lngBeginPos = lngEndFileName
End if
lngEndPos = len(strData)
lngDataLenth = lngEndPos - lngBeginPos
strFileData = mid(strData, lngBeginPos, lngDataLenth)
Set fso = CreateObject(”Scripting.FileSystemObject”)
”Dosya Adına bulunmaz kimllik ekleniyor
SagMetin = Right(FileName, 4)
saat=Hour(time)
dakika=Minute(time)
saniye=Second(time)
birlestir1=saniye&dakika&saat
tarih=Date()
tarih1=Day(tarih)
tarih2=Month(tarih)
tarih3=Year(tarih)
birlestir2=tarih1&tarih2&tarih3
FileName=yuklenecek_id&birlestir1&birlestir2&SagMetin
Set f = fso.OpenTextFile(server.mappath(imagedir) & ”/” & FileName, ForWriting, True)
f.Write strFileData
Set f = nothing
Set fso = nothing
lngNumberUploaded = lngNumberUploaded + 1
End if
lngCurrentBegin = instr(1, strDataWhole, strBoundry)
lngCurrentEnd = instr(lngCurrentBegin + 1, strDataWhole, strBoundry) - 1
loop
”Veritabanına Kaydediliyor
veriyionayla=”update uygulamalar set dosya_adi=””&FileName&” where id=”& yuklenecek_id
condb.execute(veriyionayla)
”Yönlendirme Yapılıyor
Response.Redirect ”dosya.asp?er=2”
<input NAME=”File2” class=”resimyukleme” SIZE=”30” TYPE=”file”>
<input type=”submit” value=” Yükle ” class=”resimyuklebuton” >
</form>
ForWriting = 2
adLongVarChar = 201
lngNumberUploaded = 0
noBytes = Request.TotalBytes
binData = Request.BinaryRead (noBytes)
Set RST = CreateObject(”ADODB.Recordset”)
LenBinary = LenB(binData)
if LenBinary > 0 Then
RST.Fields.Append ”myBinary”, adLongVarChar, LenBinary
RST.Open
RST.AddNew
RST(”myBinary”).AppendChunk BinData
RST.Update
strDataWhole = RST(”myBinary”)
End if
strBoundry = Request.ServerVariables (”HTTP_CONTENT_TYPE”)
lngBoundryPos = instr(1, strBoundry, ”boundary=”) + 8
strBoundry = ”--” & right(strBoundry, len(strBoundry) - lngBoundryPos)
lngCurrentBegin = instr(1, strDataWhole, strBoundry)
lngCurrentEnd = instr(lngCurrentBegin + 1, strDataWhole, strBoundry) - 1
Do While lngCurrentEnd > 0
strData = mid(strDataWhole, lngCurrentBegin, lngCurrentEnd - lngCurrentBegin)
strDataWhole = replace(strDataWhole, strData,””)
lngBeginFileName = instr(1, strdata, ”filename=”) + 10
lngEndFileName = instr(lngBeginFileName, strData, chr(34))
if lngBeginFileName = lngEndFileName and lngNumberUploaded = 0 Then
”Resim boş yükleme Yapılırsa Buraya Yönlendir
Response.Redirect ”dosya_ekle.asp?page=resim_ekle&haber_islemi=ekle&er=1&id=”&yuklenecek_id
End if
if lngBeginFileName <> lngEndFileName Then
strFilename = mid(strData, lngBeginFileName, lngEndFileName - lngBeginFileName)
tmpLng = instr(1, strFilename, ””)
Do While tmpLng > 0
PrevPos = tmpLng
tmpLng = instr(PrevPos + 1, strFilename,””)
Loop
FileName = right(strFilename, len(strFileName) - PrevPos)
lngCT = instr(1,strData, ”Content-Type:”)
if lngCT > 0 Then
lngBeginPos = instr(lngCT, strData, chr(13) & chr(10)) + 4
Else
lngBeginPos = lngEndFileName
End if
lngEndPos = len(strData)
lngDataLenth = lngEndPos - lngBeginPos
strFileData = mid(strData, lngBeginPos, lngDataLenth)
Set fso = CreateObject(”Scripting.FileSystemObject”)
”Dosya Adına bulunmaz kimllik ekleniyor
SagMetin = Right(FileName, 4)
saat=Hour(time)
dakika=Minute(time)
saniye=Second(time)
birlestir1=saniye&dakika&saat
tarih=Date()
tarih1=Day(tarih)
tarih2=Month(tarih)
tarih3=Year(tarih)
birlestir2=tarih1&tarih2&tarih3
FileName=yuklenecek_id&birlestir1&birlestir2&SagMetin
Set f = fso.OpenTextFile(server.mappath(imagedir) & ”/” & FileName, ForWriting, True)
f.Write strFileData
Set f = nothing
Set fso = nothing
lngNumberUploaded = lngNumberUploaded + 1
End if
lngCurrentBegin = instr(1, strDataWhole, strBoundry)
lngCurrentEnd = instr(lngCurrentBegin + 1, strDataWhole, strBoundry) - 1
loop
”Veritabanına Kaydediliyor
veriyionayla=”update uygulamalar set dosya_adi=””&FileName&” where id=”& yuklenecek_id
condb.execute(veriyionayla)
”Yönlendirme Yapılıyor
Response.Redirect ”dosya.asp?er=2”