Save as Word Document | Find | English | Portugues(Brasil)

Techinical Reference
Uploading Documents

How to upload documents using XMLNuke.

Table of contents
1. The IModule Interface
2. Data Repository - AnyDataSet
3. Uploading Documents
4. Grouping data entries in XMLNuke
5. Personalized validation in JavaScript
6. Adding Pieces of JavaScript Code
7. Creating your own XML objects
8. Internationalization with XMLNuke.
9. Processing Events with the Click of a Button.
10. Automatically defining the values of Properties

On this page
Upload
Observations


Upload

XMLNuke supports uploads of both simple and multiple files. The process is simplified through a single method which allows the files to be saved to the specified directory.

Building the form - CSharp
 
XmlFormCollection form = new XmlFormCollection(this._context, "module:sample", "Formulário");
XmlInputFile inf = new XmlInputFile("Upload: ", "filetoupload");
form.addXmlnukeObject(inf);

Building the form - PHP
 
$form = new XmlFormCollection($this->_context, "module:sample", "Formulário");
$fileField = new XmlInputFile("Upload", 'filetoupload');
$form->addXmlnukeObject($fileField);

Once the form is submitted, it must be treated to locate the files that were submitted and save them.

Processing the Upload - CSharp
 
// The UploadFilenameProcessor will define the path where the file will be saved.
UploadFilenameProcessor uploadFilename = 
	new UploadFilenameProcessor("common" + util.FileUtil.Slash() + "files", this._context);
uploadFilename.FilenameLocation = ForceFilenameLocation.SharedPath;

// Save the files of the form
ArrayList files = this._context.processUpload(uploadFilename, false, "filetoupload");

Processing the Upload - PHP
 
// The UploadFilenameProcessor will define the path where the file will be saved.
$fileProcessor = new UploadFilenameProcessor('*', $this->_context);
$fileProcessor->setFilenameLocation(ForceFilenameLocation::DefinePath, "common" . FileUtil::Slash() . "files");

// Save the files of the form
$result = $this->_context->processUpload($fileProcessor, false, "filetoupload");

Observations

  • The ArrayList response contains the names of the files that were saved.
  • The second argument specifies if the name will come from the file itself (false) or if it will be defined by the UploadFileNameProcessor (true).
  • The third parameter specifies that you will save ONLY the file that was submitted by the INPUT TYPE=FILE that is specified in the name.

Previous
Data Repository - AnyDataSet
Next
Grouping data entries in XMLNuke