I need to use the upload control on the web to allow a user to select a filename so I can get the path to the file, but I don’t want to actually attached the file when the document is saved.
I can’t located a method to stop / prevent attachments. I can get the upload control value, but I can’t “reset” it to “”.
Ideas anyone?
Subject: Stop or prevent File Upload - Web
Just use some javascript in the onSubmit() to move the value in the file field to a hidden text field.
Since file fields are dynamically created with weird filenames, you can use some script like below to find them. The all begin with “%%File”.
form = document.forms[0] ;
//alert(form.elements.length) ;
for (n = 0 ; n < form.elements.length ; n++) {
field = form.elements[n] ;
if (field.name.substring(0,6) == "%%File") {
alert(field.name) ;
}
}
Subject: RE: Stop or prevent File Upload - Web
Interesting thought and it does gather the field name and allow the “value” to be retrieved or evaluated. BUT, from everything else I have read the fileupload control is READ-ONLY and the value cannot be changed except manually by the user.
From all my testing and research this appears to be true.
Anymore thoughts?
BTW…The follwoing code in the onSubmit() event will validate this:
form = document.forms[0] ;
//alert(form.elements.length) ;
for (n = 0 ; n < form.elements.length ; n++) {
field = form.elements[n] ;
if (field.name.substring(0,6) == “%%File”) {
alert(field.name) ;
alert(field.value);
field.value = “TEST”;
alert(field.value);
return false
}
}
Subject: RE: Stop or prevent File Upload - Web
Use the code suggested to get the value of %%File and tuck it away somewhere safe. Then in your WQS agent, do something like:
Call docContext.RemoveItem( "$File" )