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 '12 at 5:54
  • i can give you some sample code on how to do this using Client Object Model if you want ? – Sebastien Stettler Feb 29 '12 at 7:42
  • @SebastienStettler Sure, I would love some code to do this with the COM. – Kristopher Blair Feb 29 '12 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. – Kristopher Blair Feb 29 '12 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 – Sebastien Stettler Feb 29 '12 at 14:02

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.

| improve this answer | |
  • 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 – Kristopher Blair Dec 15 '11 at 19:50
  • Ah very cool! The Upload.aspx was the missing piece. :) – Kit Menke Dec 16 '11 at 14:37
  • @KristopherBlair care to share the solution you used? – topcat3 May 14 '13 at 16:45
  • Would anyone mind actually answering the question here so that other people can use your solution? – Robert Kaucher Jul 17 '13 at 14:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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