Upload Method

The Upload method of the Imaging service uploads a file to a list on the current Web site.

Parameters

strListName   The name of the list on the current Web site.

strFolder   The relative path from the root of the list to the target folder.

bytes   The binary content in the file to be uploaded.

fileName   The file name to be used as item name in the list.

fOverWriteIfExist   A Boolean value that indicates whether a file with the same name should be overwritten. A FileExists exception is thrown if the item exists and fOverWriteIfExist is not true.

Return Value

A Microsoft.SharePoint.SoapServer.SoapXml object that returns the last modified date of the item if the operation is successful.

<results xmlns="http://schemas.microsoft.com/sharepoint/soap/ois/" lastmodified="..."/>

Error Values

The following table shows errors that may be returned by the Upload method.

Error Code Description
0x1 ListNotFound: The requested list is not found.
0x2 IsNotLibrary: The requested list, although found, is not a picture library.
0x3 ItemNotFound: The requested list item is not found.
0x4 FolderNotFound: The requested folder is not found.
0x5 InvalidArgument: One or more arguments are not valid.
0x6 FileExists: The file already exists, and the user does not specify the overwrite option.

Example

The following code example uploads an image called "Red Figure2.gif" to the "My Pictures" library on "http://Server_Name/sites/mynewsite". The code assumes that the site and the picture library already exist, that you have permissions on the server, and that the picture library contains some items. If the site and picture library do not exist, see "Create a Site and Picture Library" later in this section.

The following code example shows how to create the site and the picture library required in the earlier example. Note that you need to be a member of the Administrators site group on the Microsoft Windows SharePoint Services server to be able to add a reference to the Administrator Web service and to perform the required actions.

SOAP Request Format

The following is a sample SOAP request. You need to replace the placeholders shown with actual values.

POST /_vti_bin/imaging.asmx HTTP/1.1
Host: Server_Name
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://schemas.microsoft.com/sharepoint/soap/ois/Upload"

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <Upload xmlns="http://schemas.microsoft.com/sharepoint/soap/ois/">
      <strListName>string</strListName>
      <strFolder>string</strFolder>
      <bytes>base64Binary</bytes>
      <fileName>string</fileName>
      <fOverWriteIfExist>boolean</fOverWriteIfExist>
    </Upload>
  </soap:Body>
</soap:Envelope>

SOAP Response Format

The following is a sample SOAP response. The placeholders shown will be replaced with actual return values.

HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <UploadResponse xmlns="http://schemas.microsoft.com/sharepoint/soap/ois/">
      <UploadResult>
        <xsd:schema>schema</xsd:schema>xml</UploadResult>
    </UploadResponse>
  </soap:Body>
</soap:Envelope>

Requirements

Platforms: Microsoft Windows Server 2003

Web Reference: http://Server_Name/[sites/][Site_Name/]_vti_bin/Imaging.asmx