In this week, I have spent lot of time with finding ways to
upload attachment with list item in SharePoint 2010. Everyone knows we can achieve
this very easily using Server side code. However as my blog title suggests my
requirement was to accomplish this task without any server side code.
So here are steps to do this using html5 and Jquery
SPService library:
1.
Create a list “Test” in your SP2010 Team site.
2.
Create a Column’s like Title, Description
(Single line of text) etc.
3.
Add a tag
for Html 5 in your site master page. (v4.master).
4.
Add Meta tag in same master page .This tag tells
IE browsers to display your webpage in IE 10 mode.
5.
Create a (.aspx) page using SPD in Site Pages
library.
6.
Create a html for your custom form and file
upload control page will look like as below :
Source Code for html:
Input type “File” is html5 control, it has attribute for setting multiple files selection.Also I have used output control for displaying list of files.
7. Add a reference to Jquery library and SPServices Jquery library JavaScript files.
8. Below is source code for event capture for displaying uploaded files in my web page
This
code adds event receiver for file upload control and displays selected file
names in output list.
That’s
it your list item with multiple or single attachments will be saved
successfully.
This comment has been removed by the author.
ReplyDeleteYou just need to use attached screenshots .. It works .. :)
ReplyDeletenice blog. it helps me so much. and the code works perfectly.
ReplyDeleteIs this gonna work with ie9?ive been reading blogs that files api won't work in ie9 and older? is there any other alternative? i have no choice but to use ie9 browser for some reasons
ReplyDeleteIE 9 doesn't support file API .
ReplyDeleteHi All how you are getting the itemId please do let me know please please for me it is showing as undefined
ReplyDeleteOnce you add item to List - olist.get_itemID() will give you item id
Deletewhy my code is upload only one file
ReplyDeleteDid you copied same code as my code in above post..?
Delete