How to view an existing document? |
I have existing documents which are uploaded into the root directory, the same directory as "application", that is uploaded at the time of registration.
I want to be able to view those documents via a Controller & view, which I have already established. The Controller coding I have is:- PHP Code: <?php I guess the name of the uploaded documents would need to be standardized (chris.jpg to photo.jpg), but I'll query that once I get the document viewed. I have in the view page coding that echos the username which works OK. But I dont know the code to view documents. Can anybody help? Update I now need to learn how to standardize the document name when uploaded for example C:xampp/htdocs/member/$user/photo/chris.jpg to be automatically changed to C:xampp/htdocs/member/$user/photo/photo.jpg Anybody with any suggestions?
For one the view needs to be the last thing that you load.
You want to do something like the below code: PHP Code: $data['photo'] = 'c:\xampp\user\photos\user.jpg'; Then in your view file just echo out $photo and $docs where you want them. What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
What do you want to do with the file? If you just need to display it in a view, you only need a href link. No need to call fopen.
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/
(03-10-2020, 08:03 AM)includebeer Wrote: What do you want to do with the file? If you just need to display it in a view, you only need a href link. No need to call fopen. Thanks @includebeer a simple href link did the job. (03-10-2020, 08:00 AM)InsiteFX Wrote: For one the view needs to be the last thing that you load. Thanks @InsiteFX Im trying to avoid using the database & I do prefer @includebeer's simpler solution. However I may need your idea somewhere else in my project. |
Welcome Guest, Not a member yet? Register Sign In |