Upload attachment to SharePoint list using HTML form and JavaScript

%3CLINGO-SUB%20id%3D%22lingo-sub-2066494%22%20slang%3D%22en-US%22%3EUpload%20attachment%20to%20SharePoint%20list%20using%20HTML%20form%20and%20JavaScript%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2066494%22%20slang%3D%22en-US%22%3EPlease%20anyone%20help%20on%20how%20to%20save%20the%20attachment%20to%20SharePoint%20list%20along%20with%20fields%20from%20HTML%20form%20and%20JavaScript.%20I%20am%20new%20to%20SharePoint.%20Please%20help%20with%20example%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2066494%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3ESharePoint%20Server%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2066698%22%20slang%3D%22en-US%22%3ERe%3A%20Upload%20attachment%20to%20SharePoint%20list%20using%20HTML%20form%20and%20JavaScript%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2066698%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F929229%22%20target%3D%22_blank%22%3E%40Sriniaghalaya%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYou%20can%20use%20SharePoint%20REST%20API%20to%20upload%20attachment%20to%20SharePoint%20list%20items.%20You%20have%20to%20use%20below%20endpoint%20to%20do%20this%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-javascript%22%3E%3CCODE%3E%2F_api%2Flists%2FGetByTitle('listName')%2Fitems(%3CITEMID%3E)%2FAttachmentFiles%2Fadd(FileName%3D'%3CFILE%20name%3D%22%22%20with%3D%22%22%20extension%3D%22%22%3E%3C%2FFILE%3E%3C%2FITEMID%3E%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Echeck%20below%20links%20for%20detailed%20information%3A%3C%2FP%3E%3COL%3E%3CLI%3E%3CA%20title%3D%22Upload%20attachment%20to%20new%20item%20on%20list%20using%20REST%20API%20JQuery%20in%20SharePoint%202013%22%20href%3D%22https%3A%2F%2Fwww.enjoysharepoint.com%2Fupload-attachment-to-new-item-on-list-using-rest-api-jquery-in-sharepoint-2013%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3EUpload%20attachment%20to%20new%20item%20on%20list%20using%20REST%20API%20JQuery%20in%20SharePoint%202013%3C%2FA%3E%26nbsp%3B%3C%2FLI%3E%3CLI%3E%3CA%20title%3D%22Uploading%20Attachments%20to%20SharePoint%20Lists%20Using%20REST%22%20href%3D%22https%3A%2F%2Fsympmarc.com%2F2016%2F04%2F20%2Fuploading-attachments-to-sharepoint-lists-using-rest%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3EUploading%20Attachments%20to%20SharePoint%20Lists%20Using%20REST%3C%2FA%3E%26nbsp%3B%3C%2FLI%3E%3CLI%3E%3CA%20title%3D%22Add%20attachment%20to%20a%20list%20item%20using%20REST%20API%22%20href%3D%22https%3A%2F%2Fsharepoint.stackexchange.com%2Fquestions%2F257779%2Fadd-attachment-to-a-list-item-using-rest-api%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3EAdd%20attachment%20to%20a%20list%20item%20using%20REST%20API%3C%2FA%3E%26nbsp%3B%3C%2FLI%3E%3C%2FOL%3E%3CHR%20%2F%3E%3CP%3EPlease%20click%20%3CSTRONG%3EMark%20as%20Best%20Response%3C%2FSTRONG%3E%20if%20my%20post%20helped%20you%20to%20solve%20your%20issue.%20This%20will%20help%20others%20to%20find%20the%20correct%20solution%20easily.%20It%20also%20closes%20the%20item.%20If%20the%20post%20was%20useful%20in%20other%20ways%2C%20please%20consider%20giving%20it%20%3CSTRONG%3ELike%3C%2FSTRONG%3E.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2071403%22%20slang%3D%22en-US%22%3ERe%3A%20Upload%20attachment%20to%20SharePoint%20list%20using%20HTML%20form%20and%20JavaScript%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2071403%22%20slang%3D%22en-US%22%3EI%20am%20unable%20to%20achieve%20by%20the%20reference%20link%20provided.%20Please%20suggest%20me%20with%20details%20on%20how%20to%20achieve%3C%2FLINGO-BODY%3E
Occasional Contributor
Please anyone help on how to save the attachment to SharePoint list along with fields from HTML form and JavaScript. I am new to SharePoint. Please help with example
2 Replies

@Sriniaghalaya 

 

You can use SharePoint REST API to upload attachment to SharePoint list items. You have to use below endpoint to do this:

 

/_api/lists/GetByTitle('listName')/items(<itemId>)/AttachmentFiles/add(FileName='<file name with extension')

 

check below links for detailed information:

  1. Upload attachment to new item on list using REST API JQuery in SharePoint 2013 
  2. Uploading Attachments to SharePoint Lists Using REST 
  3. Add attachment to a list item using REST API 

Please click Mark as Best Response if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.

 

 

I am unable to achieve by the reference link provided. Please suggest me with details on how to achieve