-1

The intent of this is to have users submit applications to the client and for the client to review their information and select the best application. I am trying to display a document from a file server onto the php web page. MySQL code holds the path of the file and I'm using readfile(). I thought maybe it was the encoding or maybe it was the file type but nothing I do seems to be working. I tried using a different filetype and I tried using mb_convert_encoding to modify the encoding.

    <?php foreach ($applications as $application) : ?>        <p> Name: <?php echo $application['fname']; ?> <?php echo $application['mname']; ?> <?php echo $application['lname']; ?><br /></p>
    <?php  

    readfile ($file); ?>

   <?php endforeach; ?> 

Here's an example of the symbols that are displaying:

PK!���Ʌ)[Content_Types].xml �(�̕MK�@���!�U�m+�H��8j� ^��I���N�������Vۊ�@23���0;� �F'sQ9��N�f X�re'{=��YQ�\hg!c+�l�??�VbB�6fl��o8�r F��y�)\0�5L��ML�w��+.�E���R��{wP����~I�k�:��N,�2&��J �8����Kk�Re����J|�C��]�D� *�d(> CY|�B�s'g�*��28]Q( M}�惓#��贉���&9��̫�!�ap>v�iDK=������p���LD\i�ǟ�Zw�= R�)��;0~>�'� ���X��1�H�������fI����v �8���,�[~��oI���A��s��]�#�� �������PK!�U~��_rels/.rels �(���MK1���!̽;�"��^D�Md�C2��������(�.Ե�3y��3C֛��+�4xW��(A������yX܂JB���Wp����b��#InJ�����E�b�=[J���M�%���a �B�,o0�f@=a��� n�����o�A��;�N�

The file I'm trying to read is .doc file.

8

1 Answer 1

0

$file seems undefined; assuming $application holds all the application data you want to display to the client, then you should be doing:

<?php readfile($application['file']); ?>

If this isn't working then you aren't using the correct path - try debugging like this:

<?php var_dump($application['file'], file_exists($application['file'])); ?>
Sign up to request clarification or add additional context in comments.

2 Comments

Readfile reads data in binary mode and works with output buffers instead. Please check the docs: php.net/readfile
@user8555937 Sure it writes to the output buffer, but so does every function that outputs instead of returns and every outputting function (print, echo, var_dump, print_r, var_export...) behaves in the same way. Output buffering has nothing to do with this post.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.