Search code examples
asp.netsharepointfile-uploadsharepoint-onlinesharepoint-jsom

Sharepoint Online Upload File Form


Can I make upload file form in some sandboxed WebPart for Sharepoint Online, and if I can, how can I?

I've searched a lot and found only solutions, available for Client Object Model for outside clients, there is no example how to do this with JSOM (Client Object Model for Javascript) and usual way to upload with asp:FileUpload don't work in sandbox solution, PostedFile length = 0


Solution

  • After some search I finally found solution, based on Codeplex's SPServices. There is plugin SPWidgets(https://github.com/purtuga/SPWidgets/). This plugin loads an iframe with upload.asmx (Sharepoint's default upload form), then set display: none for all elements on this page, exept input[type=file] and adds button, wich can submit form in iframe. After submit plugin catches iframe state (_onIFramePageChange event) and do some callbacks depends on iframe url.

    This looks like some ugly workaround, but it is only working solution that I found after hours of search.