逻辑
页面上传图片
页面一个HTML展示
实现一:页面新增照片上传和删除功能 实体表中增加存储照片字段:
页面添加如图字段,隐藏14.15,14因为刷新不及时,所以利用html区域显示图片。
上传照片代码
删除照片代码
刷新照片代码
代码: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 <div><img src="%bind(:1)" width="110" height="150" ></div> rem 上传员工照片; C_HR_WRK.C_YES_NO = "N" ; rem C_PRPSINFO_TBL.EMPLOYEE_PHOTO; Local Record &recC_PRPSINFO_TBL; Local Record &recC_HR_WRK; Local Field &fld; &recC_PRPSINFO_TBL = GetRow().GetRecord(Record.C_PRPSINFO_TBL); &recC_PRPSINFO_TBL.EMPLOYEE_PHOTO.SetDefault(); &nReturn = DeleteImage(C_PRPSINFO_TBL.EMPLOYEE_PHOTO); &nReturn = InsertImage(C_PRPSINFO_TBL.EMPLOYEE_PHOTO); &nReturn = DeleteImage(C_PRPSINFO_TBL.EMPLOYEE_PHOTO); If C_HR_WRK.C_YES_NO.Value = "Y" Then Local Record &EMPL_PHOTO2 = CreateRecord(Record.C_PRPSINFO_TBL); &EMPL_PHOTO2.COUNTRY.Value = "CHN" ; &EMPL_PHOTO2.NATIONAL_ID_TYPE.Value = "NID" ; &EMPL_PHOTO2.NID_SPECIAL_CHAR.Value = C_PREHIRE0_TBL.NID_SPECIAL_CHAR.Value; rem &EMPL_PHOTO2.C_RE_NO.Value = C_PREHIRE0_TBL.C_RE_NO.Value; Local boolean &Bykey = &EMPL_PHOTO2.SelectByKey(); rem WinMessage ("&Bykey==" | &Bykey) ; &short_url = %Response.GetImageURL(&EMPL_PHOTO2); rem WinMessage ("&short_url==" | &short_url) ; rem WinMessage ("%Request.ServerPort==" | %Request.ServerPort) ; If %Request.ServerPort = 443 Then &URL_KY = &short_url; Else &URL_KY = "Http://" | %Request.ServerName | ":" | %Request.ServerPort | &short_url; End-If; rem WinMessage ("&URL_KY==" | &URL_KY) ; If All (&short_url) Then rem GetLevel0 () (1 ) .GetRowset(Scroll.C_PRPSINFO_TBL)(1 ).C_HR_WRK.HTMLAREA.Value = GetHTMLText(HTML.C_PRE_PHOTO_IMG, &URL_KY | "?" | DateTimeToLocalizedString(%Datetime, "yyyyMMddHHmmss" )); C_HR_WRK.HTMLAREA.Value = GetHTMLText(HTML.C_PRE_PHOTO_IMG, &URL_KY | "?" | DateTimeToLocalizedString(%Datetime, "yyyyMMddHHmmss" )); rem WinMessage ("&URL===" | &URL_KY | "?" | DateTimeToLocalizedString(%Datetime, "yyyyMMddHHmmss" ) ); Else rem GetLevel0 () (1 ) .GetRowset(Scroll.C_PRPSINFO_TBL)(1 ).C_HR_WRK.HR_VT_IMAGE.Value = "PT_DUMMY_PHOTO" ; C_HR_WRK.HR_VT_IMAGE.Value = "PT_DUMMY_PHOTO" ; End-If; Else MessageBox (0 , "" , 0 , 0 , "请先保存后再刷新照片" ) ; End-If;
页面新增照片展示 HTML、表,字段 创建一个HTML,用来生成一个HTML页面;添加一张图片,动态值;这里是数据动态生成的地方。备用。
建表,字段,用来接收HTML静态页面;
在页面中,创建一个HTML元件,设置为动态的展示,设置如下;
在页面生效代码中,动态获取照片数据
代码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 Local Record &EMPL_PHOTO2 = CreateRecord(Record.EMPL_PHOTO); &EMPL_PHOTO2.EMPLID.Value = C_PER_BASE_VW.EMPLID.Value; &EMPL_PHOTO2.PHOTO_SIZENAME.Value = "PAGE" ; Local boolean &Bykey = &EMPL_PHOTO2.SelectByKey(); &short_url = %Response.GetImageURL(&EMPL_PHOTO2); If %Request.ServerPort = 443 Then &URL_KY = &short_url; Else &URL_KY = "Http://" | %Request.ServerName | ":" | %Request.ServerPort | &short_url; End-If; C_EMPL_CARD_WK.C_HTML_AVATAR.Value = GetHTMLText(HTML.C_PHOTO_IMG, &URL_KY | "?" | DateTimeToLocalizedString(%Datetime, "yyyyMMddHHmmss" ));
实现二、页面上传/删除图片(标准)
对应存储表中添加:
存储照片字段 EMPLOYEE_PHOTO
照片版本字段 PSIMAGEVER
image字段属性:
注意:存储照片字段的maxlength和type 分别限制了图片的大小,类型。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 Local Record &recDBFieldDefn = CreateRecord(Record.PSDBFIELD_VW); &recDBFieldDefn.FIELDNAME.Value = "EMPLOYEE_PHOTO" ; &iImageMaxSize = &recDBFieldDefn.LENGTH.Value; &nReturn = InsertImage(LH_TEST_ZL_TBL.EMPLOYEE_PHOTO); Evaluate &nReturn When 0 Break; When 2 Break; When 3 MessageBox(%MsgStyle_OK, "" , 1000 , 22351 , "MESSAGE NOT FOUND" , MsgGetText(1000 , 22333 , "MESSAGE NOT FOUND" , &iImageMaxSize)); Break; When-Other MessageBox(%MsgStyle_OK, "" , 1000 , 22354 , "MESSAGE NOT FOUND" ); End-Evaluate;
1 2 3 4 &nReturn = DeleteImage(LH_TEST_ZL_TBL.EMPLOYEE_PHOTO); LH_TEST_ZL_TBL.EMPLID.Value = "" ; LH_TEST_ZL_TBL.PSIMAGEVER.Value = 0 ;