plUploadHandler::OnUploadComplete

This method is called when an upload of an individulal flie is complete. The filename is passed and you can then decide what to do with the file.

You can override this method to provide custom behavior in a subclass or implement the cOnUploadCompleteFunction() which fires a function with the same signature as this method. One of these typically needs to be implemented in order to do something useful with an uploaded file.

The overridden method should return a result string that is marshalled back to the JavaScript client - very commonly a URL to the uploaded file.

When overridden this method can return a string value that is passed back to the JavaScript client's completion method. Use WriteCompleteResponse() to write out that response.

**Note: **You can hook this event without subclassing by using FoxPro's BindEvent():

foxpro
foxpro
BINDEVENT(loUpldate,"OnUploadComplete",THIS,"OnUpdateComplete",1)
o.OnUploadComplete(lcFileName, loUpload)

Parameters

lcFileName

loUpload

Example

foxpro
foxpro
* ** Implemented as Process class method FUNCTION OnUploadComplete(lcFilename, loUpload) LOCAL lcUrl, lcFile * ** Resize the image lcFile = ADDBS(loUpload.cUploadPath) + lcFileName ResizeImage(lcFile,lcFile,640,480) * ** Delete expired files - only for 10 minutes DeleteFiles(ADDBS(JUSTPATH(lcFile)) + "*.*",600) * ** We'll return the URL to the image uploaded here lcUrl = this.ResolveUrl("~/temp/" + lcFileName) * ** Write out the response for the client (if any) * ** In this case the URL to the uploaded image loUpload.WriteCompletionResponse(lcUrl) ENDFUNC

See also

Class plUploadHandler

© West Wind Technologies, 2025 • Updated: 2025-03-12
Comment or report problem with topic