Hi,
Dateigröße clientseitig herausbekommen!!
hab ihr ne ahnung wie das funktionieren kann.
UlfL hat dich informiert, es ist unmöglich. (Sich selbst verbietende ActiveX Controls, VBscript
und andere Übliche verdächtige klammere ich mal aus)
Es geht also erst nach dem senden:
Ich drösel dir das mal bisschen auf, auch wenn ich dir vielleicht nix neues erzähle.....
Die Daten kommen beim server so an (ein Beispiel):
************************************************************************************************
-----------------------------7d12af3816022e
Content-Disposition: form-data; name="text1"
Testtext der allererste
-----------------------------7d12af3816022e
Content-Disposition: form-data; name="text2"
Testtext der allerzweite
-----------------------------7d12af3816022e
Content-Disposition: form-data; name="Dateiupload"; filename="F:\webs\AdminModul\community\images\_blank.gif"
Content-Type: image/gif
GIF89a€!ù,D;
-----------------------------7d12af3816022e
Content-Disposition: form-data; name="text3"
Testtext unterhalb des Files
-----------------------------7d12af3816022e--
****************************************************************************************
"-----------------------------7d12af3816022e" ist der Trenner(die "boundary", steht im @ENV)
was muss also getan werden? (schematisch)
erstmal @Array = split/boundary/, Daten;
Dann schaust du nach was innerhalb des Elements steht, welches den string "filename" enthält.
Das zerlegts du nach header und inhalt und zwar anhand der systemspezifischen
CRLF-Sequenz.
dann siehst du nach wie groß der Inhalt ist und ob er gegebenen falls bloß aus /\s*/ besteht.
Was will ich dir damit sagen? Erledige es besser mit CGI.pm.
Solltest du es doch lieber handgemacht wollen (ohne Garantie):
******************************************************************************************
#################################################################
determines the client's CRLF-sequenz, an annoying must be
#################################################################
sub define_CRLF {
local $OS = $ENV{HTTP_USER_AGENT};
if ($OS=~/vms/i) { # in VMS the Server wants LR instead of CRLF
$CRLF = "\n";
} elsif ($OS=~/^MacOS$/i) { # MAC interchanges CR and LF
$CRLF = "\n\r";
} else {
$CRLF = "\015\012";
}
}
#################################################################
parse the multipart-form into the hash "Form"
#################################################################
sub parse_multipart{
binmode STDIN;
read STDIN, $Daten, $ENV{'CONTENT_LENGTH'};
if (length($Daten) != $ENV{CONTENT_LENGTH}) { # did the user press STOP-button??
&exit_on_error('The submitted datas did not arrived complettely?<br>You probaly pressed the browsers 'STOP'-button!<br>No e-Mail has been sent!');}
# isolates the the boundarystring
($boundary = $ENV{'CONTENT_TYPE'}) =~ s/^(.+)boundary=//;
# splits the input into the subparts
@parts = split /--$boundary/, $Daten;
foreach $part (@parts)
{
local($header, $content, $name);
# seperate header from content for each part
($header, $content) = split /$CRLF$CRLF/, $part, 2;
if ($content) # only if filled
{
# gives me the name (descriptor)
($name) = ($header =~ / name="([^"]*?)"/s);
# if there is a file onBoard....
if ($header =~ /filename/s) # this is a file-upload
{
# extract the filename and clear it (who wants to know the path, Billy)
($filename) = ($header =~ /; filename="([^"]*?)"/s);
while ($filename =~ /\/) { $filename =~ s/^.*\//; }
# extract the content-type, and cut off the transfer-mode if present(mozilla-behaviour)
($mimetype) = ($header =~ /Content-Type: (.*)/s);
$mimetype =~ s/($CRLF.*)//s;
if ($filename) { # fixing a parserbug
$content =~ s/$CRLF$//gs;
$Form{$name} = $content;}
}
else # all the other fields
{
$content =~ s/$CRLF/\n/g; # to many spaces.......
if ($Form{$name} && $content) # multiple fields will be seperated by "\n"
{
chomp($content);
$Form{$name} = "$Form{$name}\n$content";
}
else
{
chomp($content);
$Form{$name} = $content;
}
}
}
}
}
******************************************************************************************
HTH,
bye eddie