Rickyg
|
| Posted: 04/08/2003, 11:03 AM |
|
I'm using the following to function to upload a image into the directory I want, as well as updating the field with the location of the image uploaded.
when I go back to edit the record, the fileupload component is not link to the image.
in the component the filefolder=c:\inetpub\wwwroot\wastewater\images
the location of the image may be in the filefolder=c:\inetpub\wwwroot\wastewater\images\P21
I've tried to set the filefolder to the image directory in the beforeshow of the component but it still will not link.
Function SoilSiteIm_FileUpload1_BeforeProcessFile() 'SoilSiteIm_FileUpload1_BeforeProcessFile @18-37093446
'Custom Code @43-73254650
' -------------------------
' Write your own code here.
dim strPath, lf, NewFolder
set lf = server.createObject( "Scripting.FileSystemObject")
if not lf.FolderExists(Server.MapPath("images/P" & SoilSiteIm.PropertyID.Value)) then
Set NewFolder = lf.CreateFolder(Server.MapPath("images/P" & SoilSiteIm.PropertyID.Value))
end if
strPath =Server.MapPath("./images/") & "/P" & SoilSiteIm.PropertyID.Value & "/"
SoilSiteIm.FileUpload1.FileFolder = strPath
' -------------------------
'End Custom Code
End Function 'Close SoilSiteIm_FileUpload1_BeforeProcessFile @18-54C34B28
Function SoilSiteIm_AfterInsert() 'SoilSiteIm_AfterInsert @2-0791DCE5
'Custom Code @44-73254650
' -------------------------
' Write your own code here.
dim strPath, last , thisPropertyID, pkWhere , picvalue, picSQL, result
strPath =("images/P") & SoilSiteIm.PropertyID.Value & "/"
thisPropertyID = CCGetParam("PropertyID", "" )
pkWhere = "(PropertyID= " & thisPropertyID & ")"
last = CCDLookUp("max(ID)", "SoilSiteImages", pkWhere, DBConnection1)
pkWhere = "(ID= " & last & ")"
picvalue = strPath & CCDLookUp("picture", "SoilSiteImages", pkWhere, DBConnection1)
picSQL = "update SoilSiteImages set picture = '" & picvalue & "' where id=" & last
result = CCExecSQL(picSQL, DBConnection1, true)
' -------------------------
'End Custom Code
End Function 'Close SoilSiteIm_AfterInsert @2-54C34B28
------------------------------------------------------------------------------
1). the folder is created
2). the file is uploaded
3). the image does exist.
4). the field is upated with the image name and location
The code works the problem is when I edit the record, the input control still appears, it never display information about the file that was uploaded.
example: if my PropertyID is 21, a c:\inetpub\wwwroot\wastewater\images\P21
directory is created if it don't exist.
If the image to upload is septictank.gif, it's location after the upload is c:\inetpub\wwwroot\wastewater\images\P21\200344127370.septictank.gif
the picture field which is a text field within the table is updated with images/P21/200344127370.septictank.gif
when I go back to edit the record the input control still appear.
in your help file it says (Note that the file input control only appears when a new record is being inserted or there is no currently existing file associated with the record being viewed. If the record being viewed has an existing file, the File Upload component will display information about the file and hide the file input control.)
I guess my question is where is the control looking for the existing file to be?
|
|
|
 |
rickyg
|
| Posted: 04/09/2003, 12:29 PM |
|
I can reset the SoilSiteIm.FileUpload1.FileFolder directory with the following code in the Page AfterInitialize
Function Page_AfterInitialize() 'Page_AfterInitialize @1-1E3DE16C
'Custom Code @68-73254650
' -------------------------
dim lf, NewFolder
set lf = server.createObject( "Scripting.FileSystemObject")
if not lf.FolderExists(Server.MapPath("images/P" & CCGetParam("PropertyID", "" ))) then
Set NewFolder = lf.CreateFolder(Server.MapPath("images/P" & CCGetParam("PropertyID", "" )))
end if
SoilSiteIm.FileUpload1.FileFolder = SoilSiteIm.FileUpload1.FileFolder & "/P" & CCGetParam("PropertyID", "" ) & "/"
' Write your own code here.
' -------------------------
'End Custom Code
End Function 'Close Page_AfterInitialize @1-54C34B28
with this code I don't need any code in the SoilSiteIm_FileUpload1_BeforeProcessFile function
and the edit record links to the image.
|
|
|
 |
|