Adds specified cookies to the upload request.
getImageUploader("ImageUploaderID").AddCookie(Cookie);
Most browsers, such as Firefox since version 2.0.0.5 or Internet Explorer (from version 6 SP1), support HTTP-only cookies. They make it impossible to read these cookies using JavaScript. It increases security and prevents your site from cross-site scripting attacks.
When Java version of Image Uploader prepares the POST request before uploading it to the server, it extracts all cookies which are downloaded along with the page that hosts Image Uploader. To get cookie, Image Uploader uses the same object model as you do in JavaScript (as if you use document.cookie). However the browser does not allow Image Uploader to get HTTP-only cookies. That is why when you post files to the server, it does not get such cookies.
Use the AddCookie() method to avoid this problem. What you need is to pass to this method cookie name-value pairs separated with semicolons:
AddCookie("Cookie1=Value1;Cookie2=Value2");
It is more convenient to use this method in the BeforeUpload event handler as it shown in the following sample. Note, this sample is for ASP.NET only.
<script type="text/javascript" src="iuembed.js"> </script> <script language="javascript"> function ImageUploader_BeforeUpload(){ if (iu.getControlType() == "Java") getImageUploader("ImageUploader").AddCookie( '<%= FormsAuthentication.FormsCookieName %>=<%=Request.Cookies[FormsAuthentication.FormsCookieName].Value %>;' + 'ASP.NET_SessionId=<%= Request.Cookies["ASP.NET_SessionId"].Value %>'); } var iu = new ImageUploaderWriter("ImageUploader", 770, 500); iu.activeXControlEnabled = false; iu.javaAppletEnabled = true; //For Java applet we specify only directory with JAR files iu.javaAppletCodeBase = "./"; iu.showNonemptyResponse = "off"; //Other parameters... //Configure URL files are uploaded to. iu.addParam("Action", "upload.aspx"); iu.addEventListener("BeforeUpload", "ImageUploader_BeforeUpload"); iu.writeHtml(); </script>
Although you can send traditional cookies this way, you should use it solely for HTTP-only cookies.
Use the ResetCookies() method to remove cookies previously added by the AddCookie() method.