backbone-model-file-upload/tests/upload-test.php

23 lines
580 B
PHP
Raw Normal View History

2014-03-18 19:16:27 +08:00
<?php
$fileName = $_FILES['fileAttachment']['name'];
$fileType = $_FILES['fileAttachment']['type'];
$fileContent = file_get_contents($_FILES['fileAttachment']['tmp_name']);
$dataUrl = 'data:' . $fileType . ';base64,' . base64_encode($fileContent);
$json = json_encode(array(
'fileAttachment' => array(
'name' => $fileName,
'type' => $fileType,
'data' => $dataUrl
),
2014-03-18 19:16:27 +08:00
'from' => $_REQUEST['from'],
'subject' => $_REQUEST['subject'],
'body' => $_REQUEST['body'],
'nestedObject' => array(
'nest' => $_REQUEST["nestedObject.nest"]
)
2014-03-18 19:16:27 +08:00
));
echo $json;
?>