How does the ASP realize to save the fax directly into the database by fax machine?

Source: Internet
Author: User
Tags format chr file system numeric value
Data | Database fax is in TIF format image saved in the file system; about how to send and receive faxes in the computer, you can refer to: http://notebook.yesky.com/ServerIndex/77128644744445952/20040823/ 1845371.shtml of articles;
I said the focus is "in TIF format images stored in the file system" You can use ASP Programming Scan this folder in the picture: and stored in the database;
There are some reference codes:
Use FSO to obtain Bmp,jpg,png,gif file information (size, width, high)
<%
'::: BMP, GIF, JPG and PNG:::

':: This function gets a specified number of bytes from::
'::: File, starting at the offset (base 1):::
'::: :::
'::: Passed::::
'::: flnm => filespec of file to read:::
'::: Offset => offset at which to start reading:::
'::: bytes => How many bytes to read::
'::: :::
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
function GetBytes (flnm, offset, bytes)
Dim objFSO
Dim objftemp
Dim objTextStream
Dim lngsize
On Error Resume Next
Set objFSO = CreateObject ("Scripting.FileSystemObject")

' We get the FileSize
Set objftemp = Objfso.getfile (FLNM)
Lngsize = Objftemp.size
Set objftemp = Nothing
fsoforreading = 1
Set objTextStream = objFSO.OpenTextFile (flnm, fsoforreading)
If offset > 0 Then
Strbuff = Objtextstream.read (offset-1)
End If
If bytes =-1 Then ' Get all!
GetBytes = Objtextstream.read (lngsize) ' ReadAll
Else
GetBytes = Objtextstream.read (bytes)
End If
Objtextstream.close
Set objTextStream = Nothing
Set objFSO = Nothing
End Function

':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
'::: :::
':: Functions to convert two bytes to a numeric value (long)::
'::: (both Little-endian and Big-endian):::
'::: :::
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
function Lngconvert (strtemp)
Lngconvert = CLng (ASC (Left (strtemp, 1)) + ((ASC (Right (strtemp, 1) * 256))
End Function
function LngConvert2 (strtemp)
LngConvert2 = CLng (ASC (Right (strtemp, 1)) + ((ASC (Left (strtemp, 1)) * 256))
End Function

':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
'::: :::
':: This function does most to the real work. It would attempt:::
'::: To read any file, regardless of the extension, and would:::
'::: Identify if it is a graphical image. :::
'::: :::
'::: Passed::::
'::: flnm => filespec of file to read:::
'::: Width => width of Image:::
'::: Height => height of Image:::
'::: Depth => color depth (in number of colors):::
'::: strimagetype=> type of image (e.g. GIF, BMP, etc.):::
'::: :::
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
function Gfxspex (flnm, width, height, depth, strimagetype)
Dim strpng
Dim strgif
Dim strbmp
Dim strtype
Strtype = ""
Strimagetype = "(unknown)"
Gfxspex = False
Strpng = Chr (137) & Chr (+) & Chr (78)
Strgif = "GIF"
Strbmp = Chr ($) & Chr (77)
Strtype = GetBytes (flnm, 0, 3)
If strtype = Strgif Then ' is GIF
Strimagetype = "GIF"
Width = Lngconvert (GetBytes (FLNM, 7, 2))
Height = Lngconvert (GetBytes (FLNM, 9, 2))
Depth = 2 ^ ((ASC (GetBytes (FLNM, 1)) and 7) + 1)
Gfxspex = True
ElseIf Left (strtype, 2) = Strbmp Then ' is BMP
Strimagetype = "BMP"
Width = Lngconvert (GetBytes (FLNM, 19, 2))
Height = Lngconvert (GetBytes (FLNM, 23, 2))
Depth = 2 ^ (ASC (GetBytes (FLNM, 29, 1))
Gfxspex = True
ElseIf strtype = Strpng Then ' is PNG
Strimagetype = "PNG"
Width = LngConvert2 (GetBytes (FLNM, 19, 2))
Height = LngConvert2 (GetBytes (FLNM, 23, 2))
Depth = GetBytes (FLNM, 25, 2)
Select Case ASC (Right (depth,1))
Case 0
Depth = 2 ^ (ASC (Left (Depth, 1))
Gfxspex = True
Case 2
Depth = 2 ^ (ASC (Left (Depth, 1)) * 3)
Gfxspex = True
Case 3
Depth = 2 ^ (ASC (Left (Depth, 1))) ' 8
Gfxspex = True
Case 4
Depth = 2 ^ (ASC (Left (Depth, 1)) * 2)
Gfxspex = True
Case 6
Depth = 2 ^ (ASC (Left (Depth, 1)) * 4)
Gfxspex = True
Case Else
Depth =-1
End Select

Else
Strbuff = GetBytes (flnm, 0,-1) ' Get all bytes from file
Lngsize = Len (strbuff)
Flgfound = 0
Strtarget = Chr (255) & Chr (216) & Chr (255)
Flgfound = InStr (Strbuff, Strtarget)
If Flgfound = 0 Then
Exit function
End If
Strimagetype = "JPG"
Lngpos = Flgfound + 2
Exitloop = False
Do While exitloop = False and Lngpos < lngsize

Do While ASC (Mid (Strbuff, Lngpos, 1)) = 255 and Lngpos < lngsize
Lngpos = lngpos + 1
Loop
If ASC (Mid (Strbuff, Lngpos, 1)) < or ASC (Mid (Strbuff, Lngpos, 1)) > 195 Then
Lngmarkersize = LngConvert2 (Mid (Strbuff, Lngpos + 1, 2))
Lngpos = lngpos + lngmarkersize + 1
Else
Exitloop = True
End If
Loop
'
If Exitloop = False Then
Width =-1
Height =-1
Depth =-1
Else
Height = LngConvert2 (Mid (Strbuff, Lngpos + 4, 2))
Width = LngConvert2



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.