...
- If you again add a file that is already present in the control you will actually get two copies of the same file there. The control cannot really know from the filename only that the files are the same.
Common settings for the FileUpload components
All components allow the following:
- restricting the file types that can be selected by specifying either their file extensions (like "png", "jpg") or the acceptable mime types ("image/jpeg").
- restricting the maximal size of the thingy that can be uploaded. This size check gets executed at the browser end if supported by the browser.
Using uploaded files
An uploaded file is represented by an UploadFile instance. Each uploaded file gets its own instance. The UploadFile data class holds:
- The remote file name of the file, as it was selected from the remote machine. This is a file name only, it has no path.
- The MIME content type of the file as specified by the browser.
- The size, in bytes, of the uploaded file
- A tempfile that contains the data from the upload.
Warning |
---|
The temp file is only valid while the page is still active/live! As soon as the page gets destroyed it will also delete all temp files that were allocated for the page. If you want to keep the data in the tempfile you must either copy or rename it. |
Upload events
The file upload component always uploads the file(s) as soon as they are selected. It does not wait for any "save" button or whatnot. One advantage of this is that the onValueChanged event for a FileUpload component fires as soon as those uploads complete, and this can be used to play with the file as soon as it is uploaded. Things you can do for instance:
- Load the file as an image, resize it using the ImageCache toolset, then replace the FileUpload control with the uploaded and rescaled image.
- Check whether the data format of the file is acceptable and if not show an error and clear the FileUpload component again.
Layout notes
The current layout uses too many classes in my op.
The layout was tested with this fiddle.