<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 6.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/URLSession/upload(for:fromFile:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "s:So12NSURLSessionC10FoundationE6upload3for8fromFileAC4DataV_So13NSURLResponseCtAC10URLRequestV_AC3URLVtYaKF"
  },
  "title" : "upload(for:fromFile:)"
}
-->

# upload(for:fromFile:)

Convenience method to upload data using a URLRequest, creates and resumes a URLSessionUploadTask internally.

```
func upload(for request: URLRequest, fromFile fileURL: URL) async throws -> (Data, URLResponse)
```

## Parameters

`request`

The URLRequest for which to upload data.

`fileURL`

File to upload.

## Return Value

Data and response.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)