Salve, ho trovato un codice per effettuare l'upload delle immagini.

Mi rimane comodo per il fatto che questa finestra viene aperta in popup, viene caricata l'immagine ed uploadata ed infine il nome dell'immagine viene inserito in un campo del form nella pagina principale.

Tutto ok, funziona bene, ma volevo poter effettuare il ridimensionamento dell'immagine tramite il wbresize di imente, prima che l'immagine venisse caricata sul server, ma non ho idea di come fare!!!


(Arriva la sfilza di codice!)
Codice PHP:
<%
'Encode JavaScript strings
Function jsEncode(text)
    jsEncode = Replace(text, "\", "\\")
    jsEncode = Replace(jsEncode, "'", "
\'")
End Function

'
Convert a String to Binary
Function string2bin(String)
    
Dim IB
    
For I=1 to len(String)
        
ChrB(Asc(Mid(String,I,1)))
    
Next
    string2bin 
B
End 
Function

'Convert a Binary to String
Function bin2string(bin)
    For i = 1 To lenB(bin)
        bin2string  = bin2string  & chr(ascB(midB(bin, i, 1)))
    Next
End Function

This function converts multibyte string to real binary data (VT_UI1 VT_ARRAY)
Function 
bin2array(bin)
    
Dim RSLMultiByteBinary
    
Const adLongVarBinary 205
    
' Using recordset
    Set RS = CreateObject("ADODB.Recordset")
    LMultiByte = LenB(bin)
    if LMultiByte>0 then
        RS.Fields.Append "mBinary", adLongVarBinary, LMultiByte
        RS.Open
        RS.AddNew
        RS("mBinary").AppendChunk bin & ChrB(0)
        RS.Update
        Binary = RS("mBinary").GetChunk(LMultiByte)
    End If
    bin2array = Binary
End Function

Server.ScriptTimeout = 600    '
10 minutes
'Read data
ReceivedBytes = Request.TotalBytes
If ReceivedBytes > 0 Then
    
    ChunkReadSize =  32768    '
Max 32 KB
    
    
    
If ReceivedBytes ChunkReadSize Then
    Response
.Write("<font face='Verdana' size='2'>Errore: Immagine troppo grande.
[url='javascript:history.back()']Riprova[/url] con una di dimensione inferiore a 32KB</font><font color='#FFFFFF'>"
)

    
End If
    
    
BytesRead 0
    Set DataStream 
createobject("ADODB.Stream")
    
DataStream.Open
    DataStream
.Type 'Binary
    Do While BytesRead < ReceivedBytes
        '
Read chunk of data
        PartSize 
ChunkReadSize
        
if PartSize BytesRead ReceivedBytes Then PartSize ReceivedBytes BytesRead
        DataPart 
Request.BinaryRead(PartSize)
        
BytesRead BytesRead PartSize
        DataStream
.Write DataPart
    Loop
    DataStream
.Position 0
    ReceivedData 
DataStream.Read
    Set DataStream 
Nothing
    Upload 
False
    Boundary 
MidB(ReceivedData1InstrB(ReceivedDatastring2bin("" vbCrLf)) - 1)
    
pos InstrB(ReceivedDatastring2bin("" vbCrLf)) + len("" vbCrLf)

    
lenCrLf Len("" vbCrLf)

    Do While 
pos ReceivedBytes
        StartPos 
InstrB(posReceivedDatastring2bin("" vbCrLf "" vbCrLf))
        If 
StartPos pos lenCrLf lenCrLf <= 0 Then
            
Exit Do
        
End If
        
Header bin2string(MidB(ReceivedDataposStartPos pos lenCrLf lenCrLf))
        
pos InstrB(posReceivedDataBoundary) - 1
        StartPos 
StartPos lenCrLf lenCrLf
        FileContent 
MidB(ReceivedDataStartPospos StartPos lenCrLf 1)
        
pos pos LenB(Boundary)

        
' Get the fields if they are compiled
        if instr(Header, "field") > 0 then
            field = bin2string(FileContent)
        end if
        if instr(Header, "path") > 0 then
            path = bin2string(FileContent)
        end if
        if instr(Header, "prev") > 0 then
            prev = bin2string(FileContent)
        end if
        if instr(Header, "thumbField") > 0 then
            thumbField = bin2string(FileContent)
        end if
        if instr(Header, "thumbPath") > 0 then
            thumbPath = bin2string(FileContent)
        end if
        if instr(Header, "thumbWidth") > 0 then
            thumbWidth = bin2string(FileContent)
        end if
        if instr(Header, "thumbHeight") > 0 then
            thumbHeight = bin2string(FileContent)
        end if
        if instr(Header, "imgWidth") > 0 then
            imgWidth = bin2string(FileContent)
        end if
        if instr(Header, "imgHeight") > 0 then
            imgHeight = bin2string(FileContent)
        end if

        ' 
Get the file to upload (if present) and write it to the server
        
If Instr(Header"upload") > 0 then
            i 
Instr(Header"filename=")
            
Instr(10Headerchr(34))
            
UploadName mid(Header1010)
            
instrRev(UploadName"\")
            If i <> 0 then
                FileName = mid(UploadName, i + 1)
            Else
                FileName = UploadName
            End If
            If FileName <> "" then
                Set binaryStream = createobject("
ADODB.Stream")
                Set FSO = CreateObject("
Scripting.FileSystemObject")
                Upload = true
                j = InStrRev(FileName, "
.")
                FileNameWithoutExtension = left(FileName, j - 1)
                Extension = right(FileName, Len(FileName) - j + 1)
                If FileName <> prev Then
                    j = 1
                    Do While FSO.FileExists(path & "
/" & FileName)
                        FileName = FileNameWithoutExtension & j & Extension
                        j = j + 1
                    Loop
                    If j > 1 Then
                        FileNameWithoutExtension = FileNameWithoutExtension & (j - 1)
                    End If
                End If
                binaryStream.Type = 1 'Binary
                binaryStream.Open
                if lenb(FileContent) > 0 then binaryStream.Write bin2array(FileContent)
                binaryStream.SaveToFile path & "
/" & FileName, 2 'Overwrite
                'If CInt(thumbWidth) > 0 Then
                    'I must create the thumbnail
                    'ResizeImage path & "
/" & FileName, thumbPath & "/" & FileNameWithoutExtension & ".jpg", "JPG", CInt(thumbWidth), CInt(thumbHeight)
                    'ThumbFile = FileNameWithoutExtension & "
.jpg"
                'End If
                'If CInt(imgWidth) > 0 Then
                    'I must resize the original image
                '    ResizeImage path & "
/" & FileName, path & "/" & FileNameWithoutExtension & ".jpg", "JPG", CInt(imgWidth), CInt(imgHeight)
                '    If LCase(Extension) <> "
.jpg" Then
                        'Delete the original file
                '        FSO.DeleteFile path & "
/" & FileName
                '    End If
                    FileName = FileNameWithoutExtension & "
.jpg"
                End If
                Set binaryStream = Nothing
                Set FSO = Nothing
            End If
        'End If
    Loop

    If Upload = True Then
%>
<html>
<head>
    <title>Upload</title>
    <meta name="
author" content="Danilo Cicognani" />
    <meta name="
robots" content="noindex,nofollow"/>
    <script language="
javascript">
        window.opener.document.<%= field %>.value = '<%= jsEncode(FileName) %>';
        <% If CInt(thumbWidth) > 0 Then %>
        window.opener.document.<%= thumbField %>.value = '<%= jsEncode(ThumbFile) %>';
        <% End If %>
        window.close();
    </script>
</head>
<body background="
img/stripe_b.gif">
</body>
</html>
<%
    End If
Else
    field = Request("
field")
    path = Request("
path")
    prev = Request("
prev")
    thumbField = Request("
thumbField")
    thumbPath = Request("
thumbPath")
    thumbWidth = Request("
thumbWidth")
    thumbHeight = Request("
thumbHeight")
    imgWidth = Request("
imgWidth")
    imgHeight = Request("
imgHeight")
End If

If Upload = False then
%>
<html>
<head>
    <title>Upload</title>
</head>
<body background="
img/stripe_b.gif">
    <h1><font face="
Verdana" size="4" color="#FE6001">Caricamento immagine</font></h1>
    
<form name="upload" action="upload.asp" method="post" enctype="multipart/form-data">
        <
input type="hidden" name="field" value="<%= field %>"/>
        <
input type="text" name="path" value="<%= path %>" size="20"/>
        <
input type="hidden" name="prev" value="<%= prev %>"/>
        <
input type="hidden" name="thumbField" value="<%= thumbField %>"/>
        <
input type="hidden" name="thumbPath" value="<%= thumbPath %>"/>
        <
input type="hidden" name="thumbWidth" value="<%= thumbWidth %>"/>
        <
input type="hidden" name="thumbHeight" value="<%= thumbHeight %>"/>
        <
input type="hidden" name="imgWidth" value="<%= imgWidth %>" size="20"/>
        <
input type="hidden" name="imgHeight" value="<%= imgHeight %>" size="20"/>
        <
input type="file" name="upload" size="20"/>
        <
input type="submit" name="submit" value="Invia"/>
    </
form>
    
    
    <
form name="upload2" action="wbresize.aspx?f=<%=img%><%= path %>&c=100&h=90&t=public/thumbs&n=thumb&r=ok.asp&e=error.asp?c=" method="post" enctype="multipart/form-data">
    <
input type="file" name="upload2" size="20"/>
    <
input type="submit" name="submit" value="Invia"/>    </form>
    
    <
font face="Verdana" size="2">
    [
url="wbresize.aspx?f=<%= upload %>&c=100&h=90&t=public/thumbs&n=thumb&r=ok.asp&e=error.asp?c="]ridimensiona[/url]</font>
    

<
font face="Verdana" size="2">La grandezza massima dell'immagine non può superare i 
    [b]32 KB[/b]</font></br>
    <font face="Verdana" size="2">Immagini supportate: jpg - jpeg - gif - bmp - png</font></p>
    </body>
</html>
<%
End If
%> 

PS: La parte del form funzionante è al primo "Invia" dove viene uploadata l'immagine.
Le altre due sezioni a seguire non funzionano (anche perchè non viene inviato il nome dell'immagine)