I am having a problem to output binary data by using PHP's header and can't figure out why, would you please help?
(the form)
<form action="upload.php" method="post" enctype="multipart/form-data">
Select image to upload:
<input type="file" name="fileToUpload" id="fileToUpload">
<input type="submit" value="Upload Image" name="submit">
</form>
</body>
</html>
(the PHP script)
<?php
require_once "connection.php";
$pic = $_FILES['fileToUpload'];
$pic_info = getimagesize($pic['tmp_name']);
$pic_mime_type = $pic_info['mime'];
$pic_data = file_get_contents($pic['tmp_name']);
$pic_size = $pic['size'];
header("Content-type: " . $pic_mime);
header("Content-length: " . $pic_size);
echo $pic_data;
?>
The output of the script is just an empty squre, would you please help?
Thanks a lot!