The following top tips for Upload for ASP.NET will help you when you use the C1Upload control.
Tip 1: Use the ValidatingFile event to perform custom handling on the file before saving to the target folder.
After files are uploaded to server, and before it is saved to the target folder, ValidatingFile event will be fired for each file. The user can perform custom validating for the uploaded files, for example, checking the size, file extension, content type etc.
Actually, any custom filtering or file operations can be performed in this event. For example, the user might want to zip the file to a smaller size, or do custom stream scanning for virus detection, or save the file to the other custom folders according to some condition etc.
The ValidateFileEventArgs contains basic file information, by which the developer can do flexible processes, even when accessing the file stream directly.
Tip 2: Use the UploadTrigger property to start uploading in suitable conditions.
Sometimes, you might not want to allow upload by clicking the [Upload] button. If so, the web developer can set the UploadTrigger property value to “Never” to prevent the built-in upload trigger and start up upload at a suitable condition.
The following example shows how a user can only upload files when he/she reads and agrees with some license etc.
<script type="text/javascript">
function StartUpload() {
if (licenseAgreed == false) return;
var uploadID = "<%= C1Upload1.ClientID %>";
var c1up = $find(uploadID);
c1up.upload();
}
</script>
|