Uploadify - First steps
Example 1 - My first upload
 
Steps:
1) Drag the control to the form.
2) In the events tab a snippet with an example will be created:
Event Uploadify1.OnAllComplete
  for &File in &UploadedFiles
    msg(&File.OriginalFileName)
  endfor
EndEvent    

Event Uploadify1.OnCancel
  &File = Uploadify1.File
  msg("Cancel:" + &File.OriginalFileName)
EndEvent

Event Uploadify1.OnError
  &File = Uploadify1.File
  msg("Error uploading file:" + &File.OriginalFileName)
  msg(Uploadify1.Error)
EndEvent
 
3) Uncomment this code and it is ready to test. Each time you perform a successful upload the "OnAllComplete" event will be triggered. In the &UploadedFile variable you will have the information of each uploaded file, if you uploaded only one file there will be only one record. Each item in the collection (file upload) will have the original name and full path of the temporary file created on the server. (if &UploadedFile is the item, &File.OriginalFileName and &UploadedFile.TemporalFileName are the original file name and the temporal full path).
 
Example 2 - Insert into the database 
If you want to insert this file into the database, you just need to assign the temporal full path to a blob variable, por example:
 
// &blob is a blob type variable, &UploadedFile UploadifyOutput variable, and &UploadedFiles is UploadifyOutput collection type
for &UploadedFile in &UploadedFiles
  &blob = &UploadedFile.TemporalFileName
  // now, you have the &blob variable loaded and ready to use, for example, calling a procedure that inserts this blob into the database (new command or Business Component)
endfor
 
 
 
Example 3 - Move uploaded file to another folder on the server
 
You can use File Data Type, for example, if you have a &file variable (File Data Type) you can do:
 
&File.Source = &UploadedFile.TemporalFileName
&File.Copy(&NewPath)
 
 
Example 4 - Change Button image
 
You can change the button image like GeneXus Marketplace "upload product" page.
 
 
In the Start Event:
UploadifyControl.ButtonImage = MyImage.Link()
Where: "UploadifyControl" is the Uploadify controlName and "MyImage" is a GeneXus Image (in this case multi-language)
 
Example 5 - Change properties in runtime
 
You can change some properties in runtime (e.g.: the button text).
To be done the change, you must execute the refresh method.
 
 
Event 'Change'
  Uploadify1.SizeLimit = &sizeLimit
  Uploadify1.ButtonImage = NewImage.Link()
  Uploadify1.Refresh()
EndEvent
 
Note:
In Java if you need to use the File data type lo load a file from a relative path (only name for example) you can use something like that:
 
java [!&pathTemp!] =  httpContext.getDefaultPath();
&File.Source = &pathTemp + "\" + &UploadifyFile.TemporalFileName 
Releated pages: