Codice PHP:
<%
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Upload con ASP by ASPCode.it - [url]http://www.aspcode.it [/url] '
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'variabili di configurazione
dim cartella
Dim folder
'folder = "images/" &cartella 'directory sul server con accesso in scrittura (ORIGINALE)
'fine variabili di configurazione
Response.Expires=0
Response.Buffer = TRUE
Response.Clear
Sub BuildUploadRequest(RequestBin)
PosBeg = 1
PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(13)))
boundary = MidB(RequestBin,PosBeg,PosEnd-PosBeg)
boundaryPos = InstrB(1,RequestBin,boundary)
Do until (boundaryPos=InstrB(RequestBin,boundary & getByteString("--")))
Dim UploadControl
Set UploadControl = CreateObject("Scripting.Dictionary")
'Get an object name
Pos = InstrB(BoundaryPos,RequestBin,getByteString("Content-Disposition"))
Pos = InstrB(Pos,RequestBin,getByteString("name="))
PosBeg = Pos+6
PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(34)))
Name = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
PosFile = InstrB(BoundaryPos,RequestBin,getByteString("filename="))
PosBound = InstrB(PosEnd,RequestBin,boundary)
If PosFile<>0 AND (PosFile<PosBound) Then
PosBeg = PosFile + 10
PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(34)))
FileName = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
UploadControl.Add "FileName", FileName
Pos = InstrB(PosEnd,RequestBin,getByteString("Content-Type:"))
PosBeg = Pos+14
PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(13)))
ContentType = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
UploadControl.Add "ContentType",ContentType
PosBeg = PosEnd+4
PosEnd = InstrB(PosBeg,RequestBin,boundary)-2
Value = MidB(RequestBin,PosBeg,PosEnd-PosBeg)
Else
Pos = InstrB(Pos,RequestBin,getByteString(chr(13)))
PosBeg = Pos+4
PosEnd = InstrB(PosBeg,RequestBin,boundary)-2
Value = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
End If
UploadControl.Add "Value" , Value
UploadRequest.Add name, UploadControl
BoundaryPos=InstrB(BoundaryPos+LenB(boundary),RequestBin,boundary)
Loop
End Sub
Function getByteString(StringStr)
For i = 1 to Len(StringStr)
char = Mid(StringStr,i,1)
getByteString = getByteString & chrB(AscB(char))
Next
End Function
Function getString(StringBin)
getString =""
For intCount = 1 to LenB(StringBin)
getString = getString & chr(AscB(MidB(StringBin,intCount,1)))
Next
End Function
byteCount = Request.TotalBytes
RequestBin = Request.BinaryRead(byteCount)
Dim UploadRequest
Set UploadRequest = CreateObject("Scripting.Dictionary")
BuildUploadRequest RequestBin
contentType = UploadRequest.Item("blob").Item("ContentType")
filepathname = UploadRequest.Item("blob").Item("FileName")
filename = Right(filepathname,Len(filepathname)-InstrRev(filepathname,"\"))
value = UploadRequest.Item("blob").Item("Value")
'checkbox creata andrea
cartella = (UploadRequest.Item("radiobutton").Item("Value"))
'Create FileSytemObject Component
Set ScriptObject = Server.CreateObject("Scripting.FileSystemObject")
'Create and Write to a File
'Modificato da andrea (al posto di cartella andava folder)
Set MyFile = ScriptObject.CreateTextFile(Server.mappath(("../images/")&cartella)&"\"&filename)
For i = 1 to LenB(value)
MyFile.Write chr(AscB(MidB(value,i,1)))
Next
Dim Conn
Set Conn=Server.CreateObject("ADODB.Connection")
Conn.Open "driver={Microsoft Access Driver (*.mdb)};dbq="& server.MapPath("../fpdb/db_sq.mdb")
'sql = "INSERT INTO tbl (campo) VALUES ('"&variabile&"')"
SQL = "INSERT INTO tGiocatori1 (image) VALUES ('"&filename&"')"
'SQL = "INSERT INTO tGiocatori1 (sq, giocatore, ruolo )"
'SQL = SQL & "VALUES ('"&sq&"' , '"&giocatore&"' , '"&ruolo&"' )"
'Response.Write "maggica SQL...: " & sql
'Response.Flush
Conn.Execute(SQL)
MyFile.Close
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="../../styles/style.css" rel="stylesheet" type="text/css" />
<script language="JavaScript" type="text/javascript">
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//-->
</script>
</head>
<body bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#FF0000" alink="#0000FF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" class="body">
<table width="459" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="459">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="59" class="testatasx"><p align="center"><font face="tahoma" color="#000000" size="2">[b]
Il
file <%=filename%> è stato uploadato con successo
E' stato salvato nella cartella <%=cartella%>[/b]</font> </p>
<p align="center"><font size="2" face="Tahoma, Verdana, Arial, SansSerif"><a href="../admin_galleryView.asp">TORNA
ALL'INDICE</a></font></p></td>
</tr>
</table></td>
</tr>
<tr>
<td height="4" class="linebianca">
</td>
</tr>
<tr>
<td>
</td>
</tr>
<tr>
<td height="4" class="linebianca">
</td>
</tr>
<tr>
<td bgcolor="#993300">
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="2%"valign="bottom"></td>
<td width="96%" align="center" class="disclaimer"></td>
<td width="2%" valign="bottom"></td>
</tr>
</table></td>
</tr>
</table>
</body>
</html>
dove sbaglio?