SharePoint 2013 file upload with Jquery -
i developing page users able upload local machines files sharepoint 2013 server.
currently have managed experiment ajax calls , use rest api creating simple .txt files , additional folders.
the problem facing response getting when trying upload .doc file or other file using arraybuffer data.
here code (which again working data passed simple string:
url = "http://temp-sharepoint/_api/web/getfolderbyserverrelativeurl('documents')/files/add(overwrite=true,url='"+filename+"')"; jquery.ajax({ url: url, type: "post", data: arraybuffer, processdata: false, headers: { "accept": "application/json; odata=verbose", "x-requestdigest": jquery("#__requestdigest").val(), "content-length": arraybuffer.bytelength }, success: dosuccess, error: onerror });
the code above result in response of
[object error]{description: "the paramet...", message: "the paramet...", name: "error", number: -2147024809, stack: "error: ..."}
which "the parameter incorrect."
again if data "test" file being created no problems.
i quite new sharepoint , appreciate if can point me possible solution.
thanks.
how reading file buffer check if contains proper data while debugging using browser debugger
sample code uploading file
function uploaddocument(buffer, filename) { var url = string.format( "{0}/_api/web/lists/getbytitle('project documents')/rootfolder/files/add(url='{1}', overwrite=true)", _sppagecontextinfo.webabsoluteurl, filename); var call = jquery.ajax({ url: url, type: "post", data: buffer, processdata: false, headers: { accept: "application/json;odata=verbose", "x-requestdigest": jquery("#__requestdigest").val(), "content-length": buffer.bytelength } }); }
Comments
Post a Comment