<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<!-- Jquery -->
</head>
<body>
<form id="uploadForm" action="upload.php" method="post">
<label>Upload Image File:</label>
<br/>
<input name="image" type="file" />
<input type="submit" value="Submit" />
</form>
<div id="ausgabe"></div>
<script type="text/javascript">
$(document).ready(function(e) {
$("#uploadForm").on('submit', (function(e) {
e.preventDefault();
$.ajax({
url: "http://something.de/bildtest.php",
type: "POST",
data: new FormData(this),
contentType: false,
processData: false,
success: function(data) {
$("#ausgabe").html(data);
},
error: function() {}
});
}));
});
</script>
</body>
</html>
Than a PHP file:
<?php
header('Access-Control-Allow-Origin: *');
header("Content-type: image/jpg");
//File Propeties
$image = file_get_contents($_FILES['image']['tmp_name']);
echo $image;
?>
Then it should echo it. When i am in the developer console of firefox i can see the right picture which is send back from the server. But in the output box in HTML file thers only code Something like this:
����JFIF``��C
��C����"�� ���}!1AQa"q2���#B��R��$3br� %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz��������������������������������������������������������������������������� ���w!1AQaq"2�B���� #3R�br� $4�%�&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz��������������������������������������������������������������������������?�EW���.QEQEW�xg��ι�� ��h�|^��gq�jj�͓#��*Y�N�ץ|8��Ix���-���j^��4��vc ѬX��
9�^'�2� ��֗����u��s谼'��T�I��[��ץ�w�%�^��q~Ȳ~����t�WX�5K_�YN�#�WqFI�0�L��? ~�_�$h��<���W�����r!TN8^�2�b0�J_�j��N����y�̳���Z6�����-m���h�P�~x�N����)nu?�%ȃ\��� �c��qk/�e/)�N�� �#msR|��>�Z��tx!ߝ"�[GP��M�B�e
I�
And so on...
What do i have to do that it becomes a normal image?