0

I added a field to upload a file/photo to my form in SharePoint using this following code. The problem with this code is that when I don't know where it store those files and is there any way I can go to the same form through "edit form" the document I attached with still be intact on it?

<tr height ="40px">
<td width="190px" valign="top" class="ms-formlabel">
<h3 class="ms-standardheader">
<nobr><b>Attach Files</b></nobr>
</h3>
</td>
<td valign="top" class="ms-formbody" id="attachmentsOnClient" style="width: 434px">
<span dir="ltr">
<input type="file" name="fileupload0"  id="onetidIOFile" size="56" title="Name">              </input>
</span>
</td>
<td width="100px" valign="top" class="ms-formbody">
<input name="Button1" type="button" value="Attach" onclick='OkAttach()'       style="width: 6em;
height: 2.5em" />
<span id="idSpace"></span>
</td>
</tr>
1
  • Can you show the js code as well? Oct 23, 2018 at 7:33

2 Answers 2

0
  1. It will store the files in the same list of NewForm.aspx that you added this control.
  2. Add the below code in CustomEditForm.aspx :

     <tr>
      <td width=”190px” valign=”top” class=”ms-formlabel”>
       <h3 class=”ms-standardheader” style=”width: 163px; height: 12px”>
        <nobr>Attachments</nobr>
       </h3>
      </td>
      </tr>
      <tr>
      <td width=”400px” valign=”top” class=”ms-formbody”>
       <SharePoint:AttachmentsField ControlMode=”Display” FieldName=”Attachments” runat=”server” Visible=”true”/>
      </td>
      </tr>
    

Edit:

  1. You can click on Edit item that has an attachment and you might be able to see the attachment in the Edit form.
0

The attachments store the same list item when the item added.

In New Item form, if you don't click the "Save" item and just attach files in form, the files will not upload to SharePoint, it don't build the store path.

The attachments store path like this:

http://siteurl/Lists/<ListName>/Attachments/<ItemID>/test.jpg

The item added process in event receiver as below.

ItemAdding->ItemAttachmentAdding->ItemAttachmentAdded->ItemAdded

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.