problem when show all image after upload

Thread is closed for posting
1 posts, 0 answers
  1. sohrab akhavan
    sohrab akhavan avatar
    1 posts
    Member since:
    Mar 2009

    Posted 11 Apr 2010 Link to this post

    I want display all image after upload, i like use upload silverlight . All step:
        1- Upload
        2- Generate thumbnail (now for testing, i just do copy to new file with prefix aa_)
        3- Display all thumbnail.

    I have a problem at step 3. the last thumbnail not display, i have to right click --> choose 'show picture'.


    <telerik:RadPane ID="RadPane2" runat="server" Width="300" BorderWidth="3" BorderColor="ActiveBorder">  
                 <input type="hidden" runat="server" id="UploadedFilesJson" /> 
                 <object data="data:application/x-silverlight," type="application/x-silverlight-2" width="280" height="120" > 
                    <param name="source" value='<%= ResolveUrl("~/Upload.xap") %>'/>  
                    <param name="onerror" value="onSilverlightError" /> 
                    <param name="background" value="white" /> 
                    <param name="minRuntimeVersion" value="2.0.31005.0" /> 
                    <param name="windowless" value="true" /> 
                    <param name="autoUpgrade" value="true" /> 
                    <param name="InitParams" value='<%= InitParameters %>'  /> 
                    <href="" style="text-decoration: none;">  
                        <img src="" alt="Get Microsoft Silverlight" style="border-style: none"/>  
                <div id="uploaded-files">  

    #Script in aspx

    <script type="text/javascript">  
                var $ = $telerik.$;  
                var uploadInProgress;  
                var uploadedFiles = new Array();  
                function updateHiddenField() {  
                    var json = Sys.Serialization.JavaScriptSerializer.serialize(uploadedFiles);  
                    $get('UploadedFilesJson').value = json;  
                // Fired when a file is uploaded  
                function onClientFileUploaded(json) {  
                    var uploadedFile = Sys.Serialization.JavaScriptSerializer.deserialize(json);  
                    var A = $("<img />")  
                    .attr("src"'<%= ResolveUrl(TargetFolder) %>' + uploadedFile.FileName)  
                    .load(function(e) { PageMethods.CreateThumbNail(uploadedFile.FileName); })  
                    Array.add(uploadedFiles, uploadedFile);  
                //Called when all files are uploaded  
                function onClientUploadFinished() {  
                    var image; var deleteFile; var html="";  
                    for (var i = 0; i < uploadedFiles.length; i++) {  
                        image = '<%= ResolveUrl(TargetFolder) %>aa_' + uploadedFiles[i].FileName  
                        html += "<img id='img_"+i.toString()+"' width='150px' src='" + image + "' /><br/>";  
                        var aa = document.getElementById("uploaded-files");  
                    aa.innerHTML = html;  
    protected string InitParameters  
                    List<string> uploadConfig = new List<string>();  
                    uploadConfig.Add("UploadServiceUrl=" + ResolveUrl("~/RadUploadHandler.ashx"));  
                    uploadConfig.Add("TargetFolder=" + ResolveUrl(TargetFolder));  
                    uploadConfig.Add("AllowedExtensions=" + "Image Files(*.gif;*.jpg;*.jpeg;*.png)");  
                    uploadConfig.Add("OverwriteExistingFiles=" + true);  
                    uploadConfig.Add("IsAutomaticUpload=" + true);  
                    uploadConfig.Add("OnClientFileUploaded=" + "onClientFileUploaded");  
                    //Name of the JavaScript function that will be called when all files are uploaded.  
                    uploadConfig.Add("OnClientFilesUploadFinished=" + "onClientUploadFinished");  
                    return String.Join(",", uploadConfig.ToArray());  
            private void PopulateUploadedFilesList()  
                if (!string.IsNullOrEmpty(UploadedFilesJson.Value))  
                    DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(List<UploadedFileInfo>));  
                    UploadedFiles = (List<UploadedFileInfo>)serializer.ReadObject(new MemoryStream(Encoding.UTF8.GetBytes(UploadedFilesJson.Value)));  
                    UploadedFilesJson.Value = string.Empty;  
            public static void DeleteFile(string fileName)  
                string uploadFolder = HttpContext.Current.Request.MapPath(TargetFolder);  
                File.Delete(Path.Combine(uploadFolder, fileName));  
            public static void CreateThumbNail(string fileName)  
                string uploadFolder = HttpContext.Current.Request.MapPath(TargetFolder);  
                string pathImg = Path.Combine(uploadFolder, fileName);  
                File.Copy(Path.Combine(uploadFolder, fileName), Path.Combine(uploadFolder, "aa_" +fileName));  

    And have a problem : the upload silverlight is disable in RadWindows when using Firefox, it ok if not use in RadWindows.
    Please view image attach
    And would you like send to me source code of Upload Silverlight that is used at here ( the source you attached is not same that in example.) I like that used in example.

    Thank you 

Back to Top