Rank: Advanced Member
Groups: Member
Joined: 4/24/2008(UTC) Posts: 31
|
Ok, I did actually find a solution now. Sorry for all the posts. Since the getAdditionalFormName method only fails on the PC in FF, I added some code so that when the user is on a Mac, getAdditionalFormName is called, but not when the user is on a PC. Fortunately, when the user is on a PC, AddField behaves more reliably when called at the BeforeUpload event. On a PC, it will read variables set by the user after IU has loaded. This isn't the case on a Mac. BeforeUpload will ignore any variables set at runtime that are added to the upload using AddField. Here's the end state of my script in case this helps you guys or someone else out there with a similar headache getting this to work across browsers. BTW, there is MooTools framework code in my script, so it's not straight JavaScript. If you copy the browser recognition part of this script, it won't work right unless you're using MooTools. You'll have to convert those lines into JavaScript or the framework of your choice. Code:
<script type="text/javascript" src="http://www.mysite.com/jscripts/iuembed.js"></script>
<div style="margin:5px; border:4px solid #ccc; padding:5px;">
<div style="width:750px; margin:8px auto;">
<script type="text/javascript">
<!--
//<![CDATA[
function fullPageLoad()
{
getImageUploader("ImageUploader1").RenameField("SourceFile_[ItemIndex]", "image");
getImageUploader("ImageUploader1").AddField("session_id","{$SESSION_ID}");
getImageUploader("ImageUploader1").AddField("s","{$SESSION_ID}");
getImageUploader("ImageUploader1").AddField("autocom","gallery");
getImageUploader("ImageUploader1").AddField("req","dopost");
getImageUploader("ImageUploader1").AddField("wardrobe","1");
getImageUploader("ImageUploader1").AddField("thumbnail","1");
getImageUploader("ImageUploader1").AddField("member_id","{$MEMBERID}");
}
function ImageUploader1_BeforeUpload() {
if ($('transparent').checked) {
getImageUploader("ImageUploader1").AddField("transparent",$('transparent').value);
}
if ($('addtocal').checked) {
getImageUploader("ImageUploader1").AddField("date_id",$('date').value);
getImageUploader("ImageUploader1").AddField("addtocal",$('addtocal').value);
}
getImageUploader("ImageUploader1").AddField("category_id",$('category_id').value);
getImageUploader("ImageUploader1").setButtonStopText("Stop");
needToHideButtonStop = false;
}
function ImageUploader1_Progress(Status, Progress, ValueMax, Value, StatusText) {
//Stop button should be displayed only during the upload process. If the upload
//completed (either successfully or not), the button should be hidden.
needToHideButtonStop = (Status=="COMPLETE" || Status=="ERROR" || Status=="CANCEL");
}
//Create JavaScript object that will embed Image Uploader to the page.
var iu = new ImageUploaderWriter("ImageUploader1", 760, 300);
//For ActiveX control full path to CAB file (including file name) should be specified.
iu.activeXControlCodeBase = "ImageUploader5.cab";
iu.activeXControlVersion = "5,1,10,0";
//For Java applet only path to directory with JAR files should be specified (without file name).
iu.javaAppletJarFileName = "ImageUploader5.jar";
iu.javaAppletCodeBase = "assets/";
iu.javaAppletCached = true;
iu.javaAppletVersion = "5.1.10.0";
iu.showNonemptyResponse = "dump";
//Set and configure advanced details view.
iu.addParam("PaneLayout", "OnePane");
iu.addParam("UploadView", "Thumbnails");
iu.addParam("DetailsPreviewThumbnailSize", "30");
iu.addParam("UploadThumbnailFitMode", "1");
iu.addParam("ShowButtons", "false");
iu.addParam("PaneBackgroundColor", "#ffffff");
if (Browser.Platform.mac) {
iu.addParam("AdditionalFormName", "advupload");
}
//Configure License Keys
iu.addParam("LicenseKey", "XXXXX-XXXXX-XXXXX-XXXXX-XXXXX");
//Configure upload settings.
iu.addParam("FilesPerOnePackageCount", "1");
iu.addParam("AutoRecoverMaxTriesCount", "1");
iu.addParam("AutoRecoverTimeOut", "10000");
iu.addParam("MaxConnectionCount", "3");
iu.addParam("AllowRotate", "false");
iu.addParam("AllowAutoRotate", "true");
iu.addParam("UploadPaneShowDescriptions", "false");
iu.addParam("DropFilesHereText", "\.jpg, \.gif \.png formats are accepted");
iu.addParam("DropFilesHereImageFormat", "Url=http://www.mysite.com/images/background_uploadbox.gif;Width=750;Height=250;Position=Center;");
if (iu.AddCookie) {
iu.AddCookie('session_id={$SESSION_ID}');
iu.AddCookie('s={$SESSION_ID}');
}
//Set several URLs files should be uploaded to. In a real life most likely
//you will specify URLs to different servers, however in this demo the single
//server and page is used for brevity.
iu.addParam("Action", "http://www.mysite.com/index.php?");
//Configure URL where to redirect after upload.
iu.addParam("RedirectUrl", "http://www.mysite.com/index.php?act=mylists&CODE=review_upload&mid={$MEMBERID}");
//Configure miscellaneous settings.
iu.addParam("ShowDebugWindow", "true");
iu.addParam("BackgroundColor", "#ffffff");
iu.addParam("ShowContextMenu", "false");
//Concurrent upload feature and advanced details view are not supported in Java version yet.
//This way we need to get Java version working in standard mode (sequential upload with standard
//progress dialog).
iu.addEventListener("BeforeUpload", "ImageUploader1_BeforeUpload");
if (iu.getControlType() == "ActiveX"){
iu.addParam("SilentMode", "false");
var needToHideButtonStop = false;
iu.addEventListener("Progress", "ImageUploader1_Progress");
//Use timer to check whether to hide the Stop button. It allows to avoid the button flickering.
window.setInterval("if (needToHideButtonStop) {getImageUploader('ImageUploader1').setButtonStopText(''); needToHideButtonStop = false;}", 500);
}
iu.fullPageLoadListenerName = "fullPageLoad";
//Tell Image Uploader writer object to generate all necessary HTML code to embed
//Image Uploader to the page.
iu.writeHtml();
//]]>
//-->
</script>
<form action="http://www.mysite.com/index.php?" id="advupload" name="advupload">
<input type="hidden" name="autocom" value="gallery" />
<input type="hidden" name="req" value="dopost" />
<input type="hidden" name="thumbnail" value="1" />
<input type="hidden" name="member_id" value="{$MEMBERID}">
<p>
<h2>Upload Images</h2>
</p>
<table style="text-align:left;" cellspacing="4" style="margin-left:20px; margin-top:10px;">
<tr valign="top">
<td align="right"><strong>Category:</strong></td>
<td align="left">
<select style="width:200px;" id="category_id" name="category_id" class="customselect" tabindex="2">
<option value="">--Not Selected</option>
{$categories}
<option value="new" style="font-style:italic;">--New Category</option>
</select>
</td>
</tr>
</table>
<br clear="all" />
<div class="formbuttonrow" style="margin-top:20px;">
<input type="button" onclick="getImageUploader('ImageUploader1').Send();" value="Upload Images" />
</div>
</form>
</div>
</div>
Edited by user Sunday, August 10, 2008 2:38:01 AM(UTC)
| Reason: Not specified
|