.NETGURU
browse
Messages   Related Types
This message was discovered on ASPFriends.com 'aspngtr' list.


A.Sinan Tiril
Merhaba

Ben bir konuda bilgi almak istiyorum.

Konu asp ile resmi servera browse yolu ile yuklemek istiyorum bunun i&#E7;in bazi bilgiler edindim ama yapamadim
Bana nasil yardimci olabilirsiniz
Reply to this message...
 
    
=?windows-1254?Q?Rahmi_Vidinlio=F0lu?=
Bunu Asp ile yapmak için önce upload edeceðin klasöre Read/Write / Execute
verilmesi icap ediyor! Daha sonra Þu þekilde bir form tanýmlýycaksýn
<form name&#"r;esimyolla" method&#"p;ost" action&#"r;esmigondereceksayfa.asp"
ENCTYPE&#"m;ultipart/form-data">
ok? Sonra form içerisinde herhangi bir yerde
<input type&#"f;ile" name&#"r;esim">
diye bir Browse olayý çýkartacaksýn! Bunlar olayýn non-asp yani HTML
bölümleri!
Þimdi gelelim Resmigondereceksayfa.asp 'ye

<%
yuklenecekyer&#".;./image/"
Response.Expires=0
Response.Clear
'Response.BinaryWrite(Request.BinaryRead(Request.TotalBytes))
byteCount &# R;equest.TotalBytes
'Response.BinaryWrite(Request.BinaryRead(varByteCount))

RequestBin &# R;equest.BinaryRead(byteCount)
Dim UploadRequest
Set UploadRequest &# C;reateObject("Scripting.Dictionary")

BuildUploadRequest RequestBin

contentType &# U;ploadRequest.Item("resim").Item("ContentType")
filepathname &# U;ploadRequest.Item("resim").Item("FileName")
filename &# R;ight(filepathname,Len(filepathname)-InstrRev(filepathname,"\"))
value &# U;ploadRequest.Item("resim").Item("Value")

if not byteCount� ;then
'FileSystemObject Tanýmlamasý
Set ScriptObject &# S;erver.CreateObject("Scripting.FileSystemObject")

'Dosya varsa formdan alýp servera binary olarak yazalým

yuklenecekyer&#".;./../image/arsalar/"
pathEnd &# L;en(Server.mappath(Request.ServerVariables("PATH_INFO")))-9
Set MyFile ScriptObject.CreateTextFile(Left(Server.mappath(Request.ServerVariables("PAT
H_INFO")),pathEnd)&yuklenecekyer& filename)

For i &# 1; to LenB(value)
MyFile.Write chr(AscB(MidB(value,i,1)))
Next

MyFile.Close
End if
resim&#fi;lename
%>

Burada iþlemin nasýl gerçekleþtiðini anlamýþsýndýr sanýrým.Ama olayý
aþaðýdaki Sub ile desteklemek lazým!
----------------------------------------Sub
Sayfasý------------------------------------------------------------------
<%
Sub BuildUploadRequest(RequestBin)
'Get the boundary
PosBeg &# 1;
PosEnd &# I;nstrB(PosBeg,RequestBin,getByteString(chr(13)))
boundary &# M;idB(RequestBin,PosBeg,PosEnd-PosBeg)
boundaryPos &# I;nstrB(1,RequestBin,boundary)
'Get all data inside the boundaries
Do until (boundaryPos&#In;strB(RequestBin,boundary &
getByteString("--")))
'Members variable of objects are put in a dictionary object
Dim UploadControl
Set UploadControl &# C;reateObject("Scripting.Dictionary")
'Get an object name
Pos InstrB(BoundaryPos,RequestBin,getByteString("Content-Disposition"))
Pos &# I;nstrB(Pos,RequestBin,getByteString("name&#");)
PosBeg &# P;os+6
PosEnd &# I;nstrB(PosBeg,RequestBin,getByteString(chr(34)))
Name &# g;etString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
PosFile InstrB(BoundaryPos,RequestBin,getByteString("filename&#");)
PosBound &# I;nstrB(PosEnd,RequestBin,boundary)
'Test if object is of file type
If PosFile<>0 AND (PosFile<PosBound) Then
'Get Filename, content-type and content of file
PosBeg &# P;osFile + 10
PosEnd &# I;nstrB(PosBeg,RequestBin,getByteString(chr(34)))
FileName &# g;etString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
'Add filename to dictionary object
UploadControl.Add "FileName", FileName
Pos InstrB(PosEnd,RequestBin,getByteString("Content-Type:"))
PosBeg &# P;os+14
PosEnd &# I;nstrB(PosBeg,RequestBin,getByteString(chr(13)))
'Add content-type to dictionary object
ContentType getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
UploadControl.Add "ContentType",ContentType
'Get content of object
PosBeg &# P;osEnd+4
PosEnd &# I;nstrB(PosBeg,RequestBin,boundary)-2
Value &# M;idB(RequestBin,PosBeg,PosEnd-PosBeg)
Else
'Get content of object
Pos &# I;nstrB(Pos,RequestBin,getByteString(chr(13)))
PosBeg &# P;os+4
PosEnd &# I;nstrB(PosBeg,RequestBin,boundary)-2
Value &# g;etString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
End If
'Add content to dictionary object
UploadControl.Add "Value" , Value
'Add dictionary object to main dictionary
UploadRequest.Add name, UploadControl
'Loop to next object
BoundaryPos&#In;strB(BoundaryPos+LenB(boundary),RequestBin,boundary)
Loop

End Sub

'String to byte string conversion
Function getByteString(StringStr)
For i &# 1; to Len(StringStr)
char &# M;id(StringStr,i,1)
getByteString &# g;etByteString & chrB(AscB(char))
Next
End Function

'Byte string to string conversion
Function getString(StringBin)
getString &#"";
For intCount &# 1; to LenB(StringBin)
getString &# g;etString & chr(AscB(MidB(StringBin,intCount,1)))
Next
End Function
%>
---------------------------------------------------------Sub
Bitti----------------------------------------------------------

Kodu tabiki ben yazmadým sýfýrdan ama iþine yarayacak hale soktum!
Umarým yeterince açýklayýcý olmuþtur!
Sevgi Ve Saygýlarýmla
Rahmi "Maniaccoder" Vidinlioðlu
E-Mail: Click here to reveal e-mail address
Web: http://www.geyikology.com

-----Original Message-----
From: A.Sinan Tiril [mailto:Click here to reveal e-mail address]
Sent: Wednesday, October 17, 2001 3:35 PM
To: aspngtr
Subject: [aspngtr] browse

Merhaba

Ben bir konuda bilgi almak istiyorum.

Konu asp ile resmi servera browse yolu ile yuklemek istiyorum bunun için
bazi bilgiler edindim ama yapamadim
Bana nasil yardimci olabilirsiniz

| [aspngtr] member Click here to reveal e-mail address &# Y;OUR ID
| http://www.asplists.com/asplists/aspngtr.asp &# J;OIN/QUIT
| http://www.asplists.com/search &# S;EARCH Archives
Reply to this message...
 
    
turkari
tam bilmemekle birlikte
html form unsuru i&#E7;indeki
<input type="file" ...
alan&#FD;nda tip olarak file belirtiliyordu zannedersem nedediniz mi ?
----- Original Message -----
From: A.Sinan Tiril
To: aspngtr
Sent: Wednesday, October 17, 2001 3:35 PM
Subject: [aspngtr] browse

Merhaba

Ben bir konuda bilgi almak istiyorum.

Konu asp ile resmi servera browse yolu ile yuklemek istiyorum bunun i&#E7;in bazi bilgiler edindim ama yapamadim
Bana nasil yardimci olabilirsiniz

| [aspngtr] member Click here to reveal e-mail address = YOUR ID
| http://www.asplists.com/asplists/aspngtr.asp = JOIN/QUIT
| http://www.asplists.com/search = SEARCH Archives
Reply to this message...
 
    
Tolga Davaz
Bunu dene....

<%@ Page Language="VB" EnableSessionState="False" EnableViewState="False"
Trace="False" Debug="False" Strict="True" %>
< <mailto:%@import> %@import Namespace="System.Data" %>
< <mailto:%@import> %@import Namespace="System.Data.SqlClient" %>
< <mailto:%@import> %@import Namespace="System.IO"%>
<script language="VB" runat=server>

Sub UploadBtn_Click(Sender as Object, E as EventArgs)
Dim imgStream as Stream
Dim imgLen as Integer
Dim imgNo_value as string
Dim imgContentType as String
Dim imgUploadedName as String

imgStream = UploadFile.PostedFile.InputStream
imgLen = UploadFile.PostedFile.ContentLength
imgUploadedName = UploadFile.PostedFile.FileName
Dim imgBinaryData(imgLen) as Byte
imgContentType = UploadFile.PostedFile.ContentType
imgNo_value = imgNo.Value

Try
If imgNo_value.Length < 1 then
imgNo_value = GetLastRightOf("\",imgUploadedName )
End if
Catch myEx as Exception
imgNo_value = GetLastRightOf("\",imgUploadedName )
End Try

Dim n as Integer = imgStream.Read(imgBinaryData, 0, imgLen)

Dim NumRowsAffected as Integer = MyDatabaseMethod(6, imgBinaryData )
If NumRowsAffected > 0 then
Response.Write ( "<BR> uploaded image " )
Else
Response.Write ( "<BR> an error occurred uploading the image.d
" )
End if

End Sub

Function GetLastRightOf(LookFor as String, myString as String) as
String
Dim StrPos as Integer
StrPos = myString.LastIndexOf(LookFor)
Return myString.SubString(StrPos + 1)
End Function

Function MyDatabaseMethod(cNo As Integer, imgbin As Byte()) As
Integer
Dim connection As SqlConnection = New
SqlConnection("server=localhost;uid= ....... ;pwd= ............. ;database............... ")
Dim command as New SQLCommand( "INSERT INTO tblCustomerPhotos
(cNo,foto) VALUES ( @cNo, @img_data)", connection )

Dim param0 As New SQLParameter( "@cNo", SqldbType.Int,9 )
param0.Value = cNo
command.Parameters.Add( param0 )

Dim param1 as New SQLParameter( "@img_data", SqldbType.Image )
param1.Value = imgbin
command.Parameters.Add( param1 )

connection.Open()
Dim numRowsAffected as Integer = command.ExecuteNonQuery()
connection.Close()

Return numRowsAffected

End Function

</script>
<html>
<title>Upload Images to a Database </title>
<body>
<form enctype="multipart/form-data" runat=server id=form1 name=form1>

Enter CNo
<input type=text id=imgNo runat="server" />

<br>Select File To Upload:
<input id="UploadFile" type=file runat=server>
<asp:button Text="Upload Me!" OnClick="UploadBtn_Click" runat=server/>
</form>
</body>
</html>
-----------------------------------------------------------

Original Message-----
From: A.Sinan Tiril [mailto:Click here to reveal e-mail address]
Sent: Wednesday, October 17, 2001 3:35 PM
To: aspngtr
Subject: [aspngtr] browse

Merhaba

Ben bir konuda bilgi almak istiyorum.

Konu asp ile resmi servera browse yolu ile yuklemek istiyorum bunun için
bazi bilgiler edindim ama yapamadim
Bana nasil yardimci olabilirsiniz

| [aspngtr] member Click here to reveal e-mail address = YOUR ID
| http://www.asplists.com/asplists/aspngtr.asp = JOIN/QUIT
| http://www.asplists.com/search = SEARCH Archives
Reply to this message...
 
 
System.Data.SqlClient.SqlConnection
System.EventArgs




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification