I am writing custom forms in javascript.

I do not have access to visual studio. I need to be able to upload a file into a document library with meta data.

I've been playing around with the Copy.asmx and the CopyToItems method, but I keep getting a 400 bad request error.

any help would be appreciated...


  • Can i get the source code for this. Looking out for this since a month.
    – user7151
    Feb 29, 2012 at 5:54
  • i can give you some sample code on how to do this using Client Object Model if you want ? Feb 29, 2012 at 7:42
  • @SebastienStettler Sure, I would love some code to do this with the COM. Feb 29, 2012 at 13:25
  • @Jeetu Unfortunately, I'm not able to share code as I'm doing this for my company. But, I will say that it comes out looking very hackish by just using the Upload.aspx page. I now have the go ahead to use Visual Studio and C#, so I can write my own uploader. Keep on the look out for Sebastien's COM code solution. That may be a much better solution than using the OOTB Upload.aspx page. Feb 29, 2012 at 13:29
  • cool will add a answer as soon as i can free up some time. is it possible for me to drop the C# COM code and then you port it to JS ? only the syntax should change the methods etc will stay the same Feb 29, 2012 at 14:02

1 Answer 1


You can't use only JavaScript to do this.

The CopyIntoItems method takes a byte[] stream parameter. This means you need to be able to read a file into a byte array and then pass this to the method. This first step isn't possible in JavaScript.

  • 1
    I've settled on a solution which involves IFRAMES and JQuery. This allows me to use SP's Upload.aspx page directly. I have used javascript in order to feed it the correct list ID. thanks for your help Dec 15, 2011 at 19:50
  • Ah very cool! The Upload.aspx was the missing piece. :)
    – Kit Menke
    Dec 16, 2011 at 14:37
  • @KristopherBlair care to share the solution you used?
    – topcat3
    May 14, 2013 at 16:45
  • Would anyone mind actually answering the question here so that other people can use your solution? Jul 17, 2013 at 14:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.