title: File uploading from web application to Sharepoint server
body: <p>This is my first time ever with Sharepoint. Here is the scenario</p>
  <ol>
  <li>I have a stand alone web application</li>
  <li>I also have a stand alone sharepoint server.</li>
  <li>Both are on different servers.</li>
  <li>I need to upload a file from web application to sharepoint</li>
  </ol>
  <p>I found 2 methods online,</p>
  <ol>
  <li>Using the webservice provided by Sharepoint (CopyIntoItems)</li>
  <li>Using jQuery library of Sharepoint webservice</li>
  </ol>
  <p>After searching the web, I think the jQuery part will not work (you can correct me).</p>
  <p>I am looking for a method that takes username/password and uploads a pdf file to Sharepoint server. The following is my C# code that tries to upload but ends up in error</p>
  <pre><code>public bool UploadFile(string file, string destination)
      {
          bool success = false;
          CopySoapClient client = new CopySoapClient();
  
          if (client.ClientCredentials != null)
              client.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
          
          try
          {
              client.Open();
              
              string filename = Path.GetFileName(file);
              string destinationUrl = destination + filename;
              string[] destinationUrls = { destinationUrl };
  
              FieldInformation i1 = new FieldInformation { DisplayName = &quot;Title&quot;, InternalName = &quot;Title&quot;, Type = FieldType.Text, Value = filename };
              FieldInformation[] info = { i1 };
              CopyResult[] result;
              byte[] data = File.ReadAllBytes(file);
  
              //uint ret = client.CopyIntoItems(filename, destinationUrls, info, data, out result);
              uint ret = client.CopyIntoItems(file, destinationUrls, info, data, out result);
  
              if (result != null &amp;&amp; result.Length &gt; 0 &amp;&amp; result[0].ErrorCode == 0)
                  success = true;
          }
          finally
          {
              if (client.State == System.ServiceModel.CommunicationState.Faulted)
                  client.Abort();
  
              if (client.State != System.ServiceModel.CommunicationState.Closed)
                  client.Close();
          }
  
          return success;
      }
  </code></pre>
  <p>I am calling the above function like this</p>
  <pre><code>UploadFile(@&quot;C:\temp\uploadFile.txt&quot;, &quot;http://spf-03:300/demo/Dokumente&quot;).ToString();
  </code></pre>
  <p>Error that i get:</p>
  <blockquote>
  <p>Error Code: Destination Invalid</p>
  <p>Error Message: The service method 'Copy' must be called on the same domain that contains the target URL.</p>
  </blockquote>