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

Is it any point to use AsyncFileUpload instead of FileUpload when I upload to a ftp server

$
0
0

In the present solution I use the standard FileUpload control. Note I upload the image file to a FTP server.
Below is the code I use to upload the image file to the ftp server

Now to my question: What would be the advantages if I instead use a AsyncFileUpload instead of the standard FileUpload that I use now ?

What I actually want is to display all the image files that have been uploaded without the page flicker(when a new page is rendered)
I want a partial update of my aspx page where only the uploaded image files is updated.

I mean I can probably do this by using the update panel and still use the standard FileUpload.

One more question.
When I use the FileUpload will a full rendered page be passed back to the browser ?


//Code
******

protected void BtnUploadBild_Click(object sender, EventArgs e)
     {
         if (!FileUploadBild1.HasFile)
         {
             this.lblWarningBild.Text = "Ladda först upp en bild ...";
         }
         else if (Path.GetExtension(FileUploadBild1.FileName).ToLower() != ".jpg" &&
                     Path.GetExtension(FileUploadBild1.FileName).ToLower() != ".png" &&
                     Path.GetExtension(FileUploadBild1.FileName).ToLower() != ".gif")
         {
             this.lblWarningBild.Text = "Andast följande filtyper godkänns (jpg,png,jpg)";
         }
         else
         {
             try
             {
                 File.Delete(path + FileUploadBild1.FileName);

                 FileUploadBild1.PostedFile.SaveAs(path + FileUploadBild1.FileName);
                 path += FileUploadBild1.FileName;

                 FileManager.HandleUpload(path, lblID.Text);

                 backEnd.InsertIntoPictures(lblID.Text, FileUploadBild1.FileName);

                 File.Delete(path);
             }
             catch (Exception ex)
             {
                 FileManager.EventLogger("BtnUploadBild_Click misslyckades", ex.Message);
                 throw ex;
             }

             //refresh
             DisplayCaseDetail(this.lblID.Text);
         }
     }

public static void HandleUpload(string path, string caseID)
    {
        try
        {
            FtpWebRequest request = (FtpWebRequest)WebRequest.Create(ftpServer + caseID);
            request.Credentials = new NetworkCredential(userName, passWord);
            request.Method = WebRequestMethods.Ftp.MakeDirectory;
            using (FtpWebResponse FTPRes = (FtpWebResponse)request.GetResponse())
            {
                UploadFile(caseID, path);
            }
        }
        catch (WebException ex)
        {
            if (ex.Response != null)
            {
                if (((FtpWebResponse)ex.Response).StatusCode == FtpStatusCode.ActionNotTakenFileUnavailable)
                {
                    UploadFile(caseID, path);
                }
            }
        }
    }

//Tony


Viewing all articles
Browse latest Browse all 5678

Trending Articles



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