title: Upload file using link button
body: <p>I wrote a procedure to upload a file into database using FileUpload control like this.</p>
  
  <pre><code> bytes = new byte[] { };
      filename = Path.GetFileName(FUProfile.PostedFile.FileName);
      contentType = FUProfile.PostedFile.ContentType;
      fileLengthInKB = FUProfile.PostedFile.ContentLength / 102400;
  
      fileName = FUProfile.PostedFile.FileName;
      fileExtension = System.IO.Path.GetExtension(fileName);
      fileMimeType = FUProfile.PostedFile.ContentType;
  
      if (FUProfile.HasFile)
      {
          try
          {
              if (matchExtension.Contains(fileExtension) &amp;&amp; matchMimeType.Contains(fileMimeType))
              {
                  if (fileLengthInKB &lt;= 102400)
                  {
                      using (Stream fs = FUProfile.PostedFile.InputStream)
                      {
                          using (BinaryReader br = new BinaryReader(fs))
                          {
                              bytes = br.ReadBytes((Int32)fs.Length);
                              clsProjects.UploadedProfile = bytes;
                              clsProjects.UploadedProfileCT = contentType;
                              clsProjects.UploadedProfileName = filename;
                          }
                      }
                  }
                  else
                  {
                      lblResult.Text = "Please choose profile file less than 1MB";
                  }
              }
              else
                  {
                      lblResult.Text = "Please choose only pdf profile file.";
                  }
              }
          catch (Exception ex)
          {
              lblResult.Text = "Upload status: The profile file could not be uploaded. The following error occured: " + ex.Message;
          }
      }
  </code></pre>
  
  <p>I want to do this by using the LinkButton on some forms. I want to select a file (appearing a diagluebox) by pressing LinkButton and save that file into database. Any idea please??</p>