Skip to content

Instantly share code, notes, and snippets.

@pwartbichler
Last active August 29, 2015 13:58
Show Gist options
  • Save pwartbichler/9950278 to your computer and use it in GitHub Desktop.
Save pwartbichler/9950278 to your computer and use it in GitHub Desktop.
Fileupload via Asset::create()
<?php
if ( $_FILES["fileupload"] ) {
$folder = Asset_Folder::getByPath("/uploads");
$asset = Asset::create(
$folder->getId(),
array(
"filename" => uniqid() . $_FILES["fileupload"]["name"],
"data" => file_get_contents($_FILES["fileupload"]["tmp_name"])
)
);
}
?>
<form enctype="multipart/form-data" method="POST" role="form">
<label for="fileupload">Fileupload:</label>
<input type="file" class="form-control" id="fileupload" name="fileupload" />
</form>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment