How to view an existing document? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: How to view an existing document? (/showthread.php?tid=75727) |
How to view an existing document? - christaliise - 03-10-2020 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? RE: How to view an existing document? - InsiteFX - 03-10-2020 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. RE: How to view an existing document? - includebeer - 03-10-2020 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. RE: How to view an existing document? - christaliise - 03-11-2020 (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. |