Gossamer Forum
Home : Products : Gossamer Links : Version 1.x :

Features to Upload-Function

Quote Reply
Features to Upload-Function
I have combine the passwort-mod (Modify) and the fileupload-mod at my Links2; at this doing i remember that alex asks for ideas to the upload for sql. Think filesize, file-typ are clear, butīs how with the picsize in width and heigth?? I have found this code in another script i use, but im not that programmer understanding it. Maybe it helps someone interested in:


sub ProcessUpld {

my ( $filename ) = @_;
my ( $width, $height );
my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
$atime,$mtime,$ctime,$blksize,$blocks)
= stat( $filename );

if ( substr ( $filename, -4, 4 ) eq ".gif" ) {
open ( FILE, $filename );
my $head;
my $gHeadFmt = "A6vvb8CC";
my $pictDescFmt = "vvvvb8";
read FILE, $head, 13;
(my $GIF8xa, $width, $height, my $resFlags, my $bgColor, my $w2h) = unpack $gHeadFmt, $head;
close FILE;
$PhotoWidth = $width;
$PhotoHeight = $height;
$PhotoSize = $size;
return;
}

if ( substr ( $filename, -4, 4 ) eq ".jpg" ) {
open ( FILE, $filename );
binmode ( FILE );
my($done)=0;
my($c1,$c2,$ch,$s,$length, $dummy)=(0,0,0,0,0,0);
my($a,$b,$c,$d);

if ( read(FILE, $c1, 1) &&
read(FILE, $c2, 1) &&
ord($c1) == 0xFF &&
ord($c2) == 0xD8 )
{
while (ord($ch) != 0xDA && !$done) {
while (ord($ch) != 0xFF) { return(0,0) unless read(FILE, $ch, 1); }
while (ord($ch) == 0xFF) { return(0,0) unless read(FILE, $ch, 1); }

if ((ord($ch) >= 0xC0) && (ord($ch) <= 0xC3)) {
return(0,0) unless read (FILE, $dummy, 3);
return(0,0) unless read(FILE, $s, 4);
($a,$b,$c,$d)= unpack("C"x4,$s);
$PhotoWidth = ($c<<8|$d);
$PhotoHeight = ($a<<8|$b);
$PhotoSize = $size;
return;
}else{
return(0,0) unless read (FILE, $s, 2);
($c1, $c2) = unpack("C"x2,$s);
$length = $c1<<8|$c2;
last if (!defined($length) | | $length < 2);
read(FILE, $dummy, $length-2);
}
}
}
return (0,0);
}
return (0,0);
}


[This message has been edited by Robert (edited December 25, 1999).]
Subject Author Views Date
Thread Features to Upload-Function Robert 2676 Dec 25, 1999, 7:46 AM
Post Re: Features to Upload-Function
Alex 2601 Dec 28, 1999, 8:45 AM
Post Re: Features to Upload-Function
pugdog 2600 Dec 28, 1999, 10:28 AM
Post Re: Features to Upload-Function
widgetz 2605 Dec 28, 1999, 5:31 PM
Post Re: Features to Upload-Function
pugdog 2606 Dec 29, 1999, 11:36 AM
Post Re: Features to Upload-Function
widgetz 2599 Dec 29, 1999, 12:11 PM
Post Re: Features to Upload-Function
pugdog 2599 Dec 29, 1999, 2:51 PM