Get FilePath Uploader (ASAP..)

Last post 06-21-2010, 11:45 PM by Kenneth. 2 replies.
Sort Posts: Previous Next
  •  06-21-2010, 6:08 AM 61893

    Get FilePath Uploader (ASAP..)

    Hi nice guys,
     
    I want to display photos after user choose multifiles from uploader box(but not yet upload)
    So I have th code like this:
     
    <script>
                    uploader=document.getElementById("<%=FileInput.ClientID %>");
                    uploader.handlequeueui=myqueueuihandler;
                    
                    function myqueueuihandler(list)
                    {
                         pNumFileTotal = list.length;
                         if(list.length > 0)                                         
                         {                      
                          var container=document.getElementById("DivListFileNamePhoto");
                          container.innerHTML="";
                          
                          var table=document.createElement("table");
                          table.style.borderCollapse="collapse";
                          table.cellSpacing=0;
                          table.cellPadding=4;  
                          table.className = 'text_333333';                                          
     
                          for(var i=0;i<list.length;i++)
                          {
                               var name=list[i ].FileName
                               var size=Math.round(list[i ].FileSize / 1024 ) // (or -1)
                               var stat=list[i ].Status // Finish|Error|Upload|Queue
                               var func=list[i ].Cancel;
                               
                               var row=table.insertRow(-1);
                               row.className = 'MyPhoto_Add-td';
                               row.insertCell(-1).innerHTML=name + ' (' + size + ' Kb)';
                               
                               var last=row.insertCell(-1);                       
                          }
                          
                          container.appendChild(table);
                          
                          document.getElementById('DivSubmitUpload').style.display = '';
                         }
                        return false; //hide the default;
                    }
    </script>
     
    How can I get full path of FileName to its the photos?
     
    Thanks for advance,
     
    Tam Phan
    vantamvtf@yahoo.com
  •  06-21-2010, 4:06 PM 61905 in reply to 61893

    Re: Get FilePath Uploader (ASAP..)

    The full path is not supported, you can refer to http://cutesoft.net/forums/thread/57628.aspx 
     
    Regards,
    Eric
  •  06-21-2010, 11:45 PM 61923 in reply to 61893

    Re: Get FilePath Uploader (ASAP..)

    HI hochiminh,
     
    Try this example.
     
    Create the page name "humbnail.aspx".
     
    1. <%@ Page Language="C#" %>   
    2. <%@ Import Namespace="CuteWebUI" %>   
    3. <%@ Register TagPrefix="CuteWebUI" Namespace="CuteWebUI" Assembly="CuteWebUI.AjaxUploader" %>   
    4. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">   
    5.   
    6. <script runat="server">   
    7.   
    8.     protected override void OnInit(EventArgs e)   
    9.     {   
    10.         base.OnInit(e);   
    11.            
    12.         string st=Request.QueryString["ShowThumbnail"];   
    13.         if (st != null)   
    14.         {   
    15.             MvcUploader uploader = new MvcUploader(Context);   
    16.             Guid guid = new Guid(st);   
    17.             MvcUploadFile file = uploader.GetUploadedFile(guid);   
    18.             if (file == null)   
    19.             {   
    20.                 Response.StatusCode = 404;   
    21.                 Response.Write("Invalid File : "+guid);   
    22.                 Response.End();   
    23.             }   
    24.             using (System.Drawing.Image thumbnail = new System.Drawing.Bitmap(64, 64, System.Drawing.Imaging.PixelFormat.Format32bppArgb))   
    25.             {   
    26.                 using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(thumbnail))   
    27.                 {   
    28.                     using (Stream stream = file.OpenStream())   
    29.                     {   
    30.                         using (System.Drawing.Image img = System.Drawing.Image.FromStream(stream))   
    31.                         {   
    32.                             g.DrawImage(img   
    33.                                 , new System.Drawing.Rectangle(0, 0, thumbnail.Width, thumbnail.Width)   
    34.                                 , new System.Drawing.Rectangle(0, 0, img.Width, img.Width)   
    35.                                 , System.Drawing.GraphicsUnit.Pixel);   
    36.                         }   
    37.                     }   
    38.                 }   
    39.                 MemoryStream ms = new MemoryStream();   
    40.                 thumbnail.Save(ms, System.Drawing.Imaging.ImageFormat.Png);   
    41.                    
    42.                 Response.ContentType = "image/png";   
    43.                 Response.Cache.SetExpires(DateTime.Now.AddYears(1));       
    44.                 Response.AddHeader("Content-Length",ms.Length.ToString());   
    45.                 Response.BinaryWrite(ms.ToArray());   
    46.                 Response.End();   
    47.             }   
    48.         }   
    49.     }   
    50.        
    51. </script>   
    52.   
    53. <html xmlns="http://www.w3.org/1999/xhtml">   
    54. <head id="Head1" runat="server">   
    55.     <title>Untitled Page</title>   
    56. </head>   
    57. <body>   
    58.     <form id="form1" runat="server">   
    59.         <div>   
    60.             <CuteWebUI:UploadAttachments runat="server" ID="UploadAttachment1">   
    61.                 <ItemTemplate>   
    62.                     <asp:Image runat=server ID=Image1 ImageUrl='<%# "Thumbnail.aspx?ShowThumbnail=" + Eval("FileGuid")  %>' />   
    63.                 </ItemTemplate>   
    64.             </CuteWebUI:UploadAttachments>   
    65.         </div>   
    66.         <div id='queuediv'>   
    67.         </div>   
    68.     </form>   
    69.   
    70.     <script type="text/javascript">   
    71.     function CuteWebUI_AjaxUploader_OnQueueUI(list)   
    72.     {   
    73.         var container=document.getElementById("queuediv");   
    74.         if(list.length<1)   
    75.         {   
    76.             container.style.display="none";   
    77.             return false;   
    78.         }   
    79.   
    80.         container.style.display="";   
    81.         container.innerHTML="";   
    82.            
    83.         var table=document.createElement("table");   
    84.         table.style.borderCollapse="collapse";   
    85.         table.cellSpacing=0;   
    86.         table.cellPadding=4;   
    87.         table.border=1;   
    88.         table.borderColor="darkgreen";   
    89.         table.style.fontSize="9pt";   
    90.   
    91.         for(var i=0;i<list.length;i++)   
    92.         {   
    93.                 var name=list[i].FileName   
    94.                 var size=list[i].FileSize // (or -1)   
    95.                 var stat=list[i].Status // Finish|Error|Upload|Queue   
    96.                 var func=list[i].Cancel;   
    97.                 var row=table.insertRow(-1);   
    98.                 row.insertCell(-1).innerHTML=name;   
    99.                 var last=row.insertCell(-1);   
    100.                 if(stat=="Queue")   
    101.                 {          
    102.                         var btn=document.createElement("A");   
    103.                         btn.href="BLOCKED SCRIPTvoid(0)";   
    104.                         btn.onclick=func;   
    105.                         btn.innerHTML="cancel";   
    106.                         last.appendChild(btn);   
    107.                 }   
    108.                 else if(stat=="Finish")   
    109.                 {   
    110.                     last.innerHTML="<img src='Thumbnail.aspx?ShowThumbnail=" + list[i].FileGuid+"' />";   
    111.                 }   
    112.                 else  
    113.                 {   
    114.                         last.innerHTML=stat;   
    115.                 }   
    116.         }   
    117.         container.appendChild(table);   
    118.            
    119.         return false//hide the default;   
    120.     }   
    121.     </script>   
    122.   
    123. </body>   
    124. </html>  

    Regards,
     
    Ken
View as RSS news feed in XML