Documentation > CMS Template API Library > Asset > CreateFromUploadedFile(String,Asset,UploadedFile)

CreateFromUploadedFile

Create a binary (uploaded asset) from an UploadedFile object.

public CrownPeak.CMSAPI.Asset CreateFromUploadedFile(String,Asset,UploadedFile)


Returns

A new Asset object if it is successful, null if not successful, check context.Error

Parameters

NameDescriptionType
label The name of the asset - must be unique. System.String
saveLocation The folder to store the asset. CrownPeak.CMSAPI.Asset
uploadedFile The uploaded file object to save. CrownPeak.CMSAPI.UploadedFile

Code Example

C#

Sample:
Asset image = Asset.Load("/Site/scripts/data.jpg");

Asset newAsset = Asset.CreateFromUploadedFile("test.jpg", asset.Parent, image);

// or in post_input.aspx:
Asset.CreateFromUploadedFile("image_asset.jpg", asset.Parent, context.InputForm.UploadedFiles["image_upload_source"]);    

Connect with Crownpeak