Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all articles
Browse latest Browse all 5678

how to use multiple asyncfileupload!!

$
0
0

hi i have the following code which uses ajaxtoolkit asynFileupload control to upload files

now i need to have around 20 asyncfileupload control and i don't know how to do it easily since i should create 20 javascript codes and control and upload controls!!!

i need sth like for i=0 to n to create them dynamically

<script type="text/javascript">
      function uploadComplete(sender, args) {
          try {
              var fileExtension = args.get_fileName();
              var jpg = fileExtension.indexOf('.jpg');
              var gif = fileExtension.indexOf('.gif');
              var swf = fileExtension.indexOf('.swf');
              var filesizeuploaded = parseInt(args.get_length());
              if (jpg > 0 || gif > 0 || swf > 0 &&  (filesizeuploaded < 1000000)) {
                  $get("dvFileInfo").style.display = 'block';
                  $get("dvFileErrorInfo").style.display = 'none';
                  $get("<%=uploadsuccess.ClientID%>").innerHTML;

              }
              else {
                  $get("dvFileErrorInfo").style.display = 'block';
                  $get("<%=uploaderror.ClientID%>").innerHTML = 'invalid image';
                  $get("dvFileInfo").style.display = 'none';
                  return;
              }

          }
          catch (e) {

              $get("<%=uploaderror.ClientID%>").innerHTML = e.message;
          }
      }

</script>


 <div id="photoUpload">
                                              
                                    <asp:AsyncFileUpload ID="FileBannerUpload" runat="server" BackColor="AliceBlue" UploadingBackColor="Red"
                                        OnUploadedComplete="UploadBannerImage" OnClientUploadComplete="uploadComplete" ThrobberID="throbber" />
                              
                                    <asp:Label runat="server" ID="txtUploadMessage" Style="display: none;">
                                      <img alt="" src="img/Loading.gif" />
                                    </asp:Label>
                                    <div style="display: none; font-family: Courier; width: 600px" id="dvFileInfo">
                                        <asp:Label ID="uploadsuccess" ForeColor="Blue" runat="server" Text='file uploaded success' /><br />
                                    </div>
                                    <div style="display: none; font-family: Courier; width: 800px" id="dvFileErrorInfo">
                                        <asp:Label ID="uploaderror" ForeColor="Red" runat="server"  /><br />
                                    </div>
                                </div>
                 </div>


    Protected Sub UploadBannerImage(ByVal sender As Object, ByVal e As System.EventArgs)
            System.Threading.Thread.Sleep(1000)
            If FileBannerUpload.HasFile Then
                Dim fileuploadreceive1 As String = FileBannerUpload.PostedFile.FileName
                Dim uploadedfilesize As Integer = FileBannerUpload.PostedFile.ContentLength
                Dim filename1 As String = System.IO.Path.GetFileName(fileuploadreceive1)
                If ((System.IO.Path.GetExtension(fileuploadreceive1).Contains(".jpg")) Or _
                    ((System.IO.Path.GetExtension(fileuploadreceive1).Contains(".swf")) Or _
                    ((System.IO.Path.GetExtension(fileuploadreceive1).Contains(".JPG")) Or _
                     (System.IO.Path.GetExtension(fileuploadreceive1).Contains(".gif")) _
And (uploadedfilesize < config.maxPhotoSize * 1024)))) Then
                    fileExtension = System.IO.Path.GetExtension(FileBannerUpload.FileName).ToLower()
               
                    FileName = common.hexValue(8)
                    newFileName = FileName + fileExtension

                    Dim fileuploadpath1 As String = config.physicalPath & "\pictures\"
                    FileBannerUpload.PostedFile.SaveAs(System.IO.Path.Combine(fileuploadpath1, newFileName))

                End If
            End If
        End Sub


Viewing all articles
Browse latest Browse all 5678

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>