Rank: Member
Groups: Joined: 9/25/2006(UTC) Posts: 10
|
Hi, I'm testing out the method you outlined, but I'm running into a slight problem. I can manually implement the 2 phase upload you described, but I can't do it automatically. I see, to be having problems with these 2 methods: iu.addParam("UncheckUploadedFiles", "false"); iu.Send(); after the first step of the upload, the upload list is always reset, so there is nothing to remove from the upload list. Am I doing something wrong? Here's my script: Code://<![CDATA[
//Create JavaScript object that will embed Image Uploader to the page.
var iu = new ImageUploaderWriter("ImageUploader1", 550, 490);
//For ActiveX control full path to CAB file (including file name) should be specified.
iu.activeXControlCodeBase = "javascripts/ImageUploader4.cab";
iu.activeXControlVersion = sc.activeXControlVersion;
//For Java applet only path to directory with JAR files should be specified (without file name).
iu.javaAppletCodeBase = "javascripts/";
iu.javaAppletCached = true;
iu.javaAppletVersion = sc.javaAppletVersion;
iu.showNonemptyResponse = "off";
//Configure appearance and behaviour.
iu.addParam("PaneLayout", "TwoPanes");
//iu.addParam("FolderView", "Thumbnails");
iu.addParam("FolderView", "Details");
iu.addParam("UploadView", "Details");
iu.addParam("PreviewThumbnailSize", "100");
iu.addParam("ShowButtons", "false");
iu.addParam("ShowSubfolders", "true");
iu.addParam("ShowDescriptions", "false");
iu.addParam("ShowContextMenu", "false");
iu.addParam("ShowDebugWindow", "true");
iu.addParam("AllowMultipleRotate", "true");
//Configure colors.
iu.addParam("PaneBackgroundColor", "#ffffff");
iu.addParam("BackgroundColor", "#ffffff");
iu.addParam("PreviewThumbnailActiveColor", "#f8b330");
iu.addParam("PreviewThumbnailInactiveColor", "#eeeeee");
//Hide tree pane.
iu.addParam("TreePaneWidth", "-1");
//Allow upload not only files, but also entire folders.
//iu.addParam("AllowFolderUpload", "true");
//Single or multiple file selection.
//iu.addParam("AllowMultipleSelection", "false");
//Link ImageUploader with ShellComboBox.
iu.addParam("AdditionalFolderNavigator", "ImageUploader");
//Configure file mask to display images only.
iu.addParam("FileMask", "*.jpg;*.jpeg;*.jpe;*.gif;*.png;*.tif;*.tiff;*.psd");
//Configure thumbnail settings.
iu.addParam("UploadThumbnail1Width", "60");
iu.addParam("UploadThumbnail1Height", "60");
iu.addParam("UploadThumbnail1JpegQuality", "60");
//iu.addParam("UploadThumbnail1CopyExif", "true");
//Configure upload settings.
iu.addParam("Action", "upload");
iu.addParam("FilesPerOnePackageCount", "10");
iu.addParam("AutoRecoverMaxTriesCount", "2");
iu.addParam("AutoRecoverTimeOut", "10000");
//Configure Image Uploader to rotate photos automatically
//according to the orientation stored in EXIF metadata.
iu.addParam("EnableAutoRotate", "true");
//Append the form with total file size to the upload.
iu.addParam("AdditionalFormName", "Form1");
//2 phase upload Prepare
iu.addParam("UploadThumbnail1FitMode", "fit");
iu.addParam("UploadThumbnail1CopyExif", "true");
iu.addParam("AllowFolderUpload", "true");
iu.addParam("UploadSourceFile", "false");
iu.addParam("UncheckUploadedFiles", "false");
//Add event handlers.
iu.addEventListener("UploadFileCountChange", "ImageUploader_UploadFileCountChange");
iu.addEventListener("Progress", "ImageUploader_Progress");
iu.fullPageLoadListenerName = "FullPageLoad";
//Tell Image Uploader writer object to generate all necessary HTML code to embed
//Image Uploader to the page.
iu.writeHtml();
//]]>
</script>
<script type="text/javascript">
//<![CDATA[
//This UploadFileCountChange event handler displays total size of all files selected for upload.
function ImageUploader_UploadFileCountChange(){
var imageUploader1 = getImageUploader("ImageUploader1");
if (imageUploader1){
document.getElementById("TotalSourceFileSize").value = Math.ceil(imageUploader1.getTotalFileSize() / 1024);
}
}
//This Progress event handler demonstrates an alternative way to
//redirect upon upload (instead of RedirectUrl property).
var WasUpload = false;
function ImageUploader_Progress(Status, Progress, ValueMax, Value, StatusText)
{
if (Status=="COMPLETE")
{
if (WasUpload)
{
WasUpload = false;
window.location = 'gallery';
return;
}
// StatusText contains Response from server.
// Remove unwanted files from upload list
var iu = getImageUploader("ImageUploader1");
//if (iu) {alert('start remove mode');}
// var n;
// var removeList = new Array(1,2);
// for (n in removeList)
// {
// alert(' remove ' + removeList[n] + '');
// iu.UploadFileRemove(removeList[n]);
// }
alert('preparing for source upload');
// During next upload source files will be sent
iu.UploadSourceFile = true;
iu.UncheckUploadedFiles = true;
iu.UploadThumbnail1FitMode = "Fit";
WasUpload = true;
alert('finished preparing for source upload');
iu.Send();
iu.MessageUploadCompleteText = "Source Upload complete";
}
}
//]]>
Edited by user Tuesday, February 19, 2008 2:50:23 PM(UTC)
| Reason: Not specified
|