if ($photo) { $photoname = join ("", 'ch',$count,'.jpg'); open (OUTFILE,"> $photodir$photoname") or die "Cant open photofile: $!"; while (read($photo,$buffer,1024)) { print OUTFILE $buffer; } close(OUTFILE); }