Skip to content
Snippets Groups Projects
Commit 0a4edc26 authored by Rafael Ostertag's avatar Rafael Ostertag
Browse files

Added file upload mock.

parent 137cf67d
No related branches found
No related tags found
No related merge requests found
<?php
/**
* @author Rafael Ostertag <rafael.ostertag@math.uzh.ch>
*/
var_dump($_POST);
foreach ($_FILES as $key => $value) {
echo "$key";
echo file_get_contents($value['tmp_name']);
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Upload</title>
</head>
<body>
<form id="myform">
<label>File
<input name="fileupload" id="fileupload" type="file"></label>
<button id="doupload">Upload</button>
</form>
<pre id="display"></pre>
<script src="../js/jquery.min.js"></script>
<script>
$(function () {
$('#doupload').click(function (event) {
event.preventDefault();
var data = new FormData();
$('input[type=file]').each(function (index, object) {
$.each(this.files, function (key, value) {
data.append($(object).attr('name') + '_' + key, value);
});
});
data.append('sip', 'sip_goes_here');
$.ajax({
url: 'api/uploadhandler.php',
type: 'POST',
data: data,
cache: false,
processData: false,
contentType: false
}).done(function (data) {
$("#display").empty().append(data);
});
});
});
</script>
</body>
</html>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment