BlogSphere - Response: Solution Proposed for the upload problem
Here are the modifications I proposed to fix this problem.
The idea is to save the image imported from the File Upload Control, create a URL for the image and send it back to the calling window. To do this :
* Add a SaveOptions field to the "FCKeditorConnector form". Set it to "0". This is to make sure that the form is not saved unless we want it to
* In the WebQuerySave event, add the following: @Command([ToolsRunMacro]; "(WQS.NewImage)")
* Create a new agent, "(WQS.NewImage)", run from Agent List, Target None
* In the Initalize event of the agent, add the following code :
Sub Initialize
Dim s As NotesSession
Dim doc As NotesDocument
Set s = New NotesSession
Set doc = s.DocumentContext
'check if the user has added a file attachment to the document
Dim FileName As Variant
FileName = Evaluate(|@Subset(@AttachmentNames; 1)|, doc)
If fileName(0) = "" Then
'the user has not selected a file, simply close the window set the focus on the "calling window"
'the document will not be saved
Print "<SCRIPT LANGUAGE=JavaScript>"
Print |window.top.opener.SetUrl('' ) ;|
Print "window.top.close();"
Print "window.top.opener.focus() ;"
Print "</SCRIPT>"
Else
'a file was added - it's ok to save the document
doc.saveOptions = "1"
'for display in the "(images)" view, we move the file name in the "ImageName" field
doc.ImageName = FileName(0)
'we could add code here to transfer the attachment to the ImageFile field
'but if the user has uploaded a big image, this could take a while and freeze the browser - this task could be run on a nightly basis instead
doc.form = "Image"
Print "<SCRIPT LANGUAGE=JavaScript>"
'build the url for the new image
Print | window.top.opener.SetUrl('/'+ location.pathname.slice( 1, location.pathname.toLowerCase().lastIndexOf('.nsf')+4) + '/' + '(Images)/| + doc.UniversalID + |/$File/| + doc.ImageName(0) +|' ) ;|
'we close the window and set the focus on the "calling window"
Print "window.top.close();"
Print "window.top.opener.focus() ;"
Print "</SCRIPT>"
End If
End Sub
Any suggestions or comments are welcomed!
Alexandre Leduc
www.alexetsandra.net/blog/alex
Documents