Using BLOB TO PICTURE with pictures uploaded from a browser
When using the command BLOB TO PICTURE with a picture uploaded from a browser, the BLOB has header data causing the command BLOB TO PICTURE to return 0. To avoid this problem, the BLOB needs to be stripped of its header contents before you convert the BLOB to a picture. The following code below will strip the header and convert it to a picture.
`Strip header method
If (BLOB size(myfile)>0)
C_STRING(255;$fileHeader)
$offset:=0
$fileHeader:=BLOB to text(myfile;Text without length ;$offset;255)
$fileNameBegin:=Position("filename=";$fileHeader)+10
For ($i;$fileNameBegin;255)
If ($fileHeader[[$i]]=Char(Double quote ))
$fileNameEnd:=$i
$i:=255
End if
End for
$fileName:=Substring($fileHeader;$fileNameBegin;$fileNameEnd-$fileNameBegin)
$contentTypeBegin:=Position("Content-Type:";$fileHeader)+14
For ($i;$contentTypeBegin;255)
If ($fileHeader[[$i]]=Char(Carriage return ))
$contentTypeEnd:=$i
$i:=255
End if
End for
contentType:=Substring($fileHeader;$contentTypeBegin;$contentTypeEnd-$contentTypeBegin)
DELETE FROM BLOB(myfile;0;$contentTypeEnd+3)
CREATE RECORD([Table 1])
BLOB TO PICTURE(myfile;[Table 1]Field2)
SAVE RECORD([Table 1])
Комментариев нет:
Отправить комментарий