![]() |
reply soon ..please plase .how to show doc file - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: reply soon ..please plase .how to show doc file (/showthread.php?tid=35203) |
reply soon ..please plase .how to show doc file - El Forum - 10-22-2010 [eluser]prabhatshishodia[/eluser] i have uploaded the doc file using upload function.and save it resume folder.how i retrieve this doc file.suppose i click mr jone his profile show me and resume link.when i click resume it show uploaded resume.please reply soon reply soon ..please plase .how to show doc file - El Forum - 10-22-2010 [eluser]Narkboy[/eluser] Could you clarify exactly what you need help with? If you've uploaded a file, any file, then you can link to it directly. If you've saved "resume.doc" to the "/resume/" folder, then the link would be "/resume/resume.doc". If you've saved it ouside the web root then you need a little bit of header trickery to allow people to view or download it In your controller try: Code: if (file_exists($file)) { Set $file to be "/resume/resume.doc" (in this example) then this will check the file is there, and output it to the browser directly. If the browser has an associated viewer it will display in the browser (like a PDF for example), otherwise you'll get a download box. Think that's what you need? /B reply soon ..please plase .how to show doc file - El Forum - 10-22-2010 [eluser]prabhatshishodia[/eluser] sir i m new with codeigniter .i have saved resume of different persons .how i get simple link to open the resume of all for example name resume jack open resume hari open resum when i click open resume in front of particular user how i get the link through anchor tag. i have save with name in resume folder.please help me how i provide link to open particular resume. reply soon ..please plase .how to show doc file - El Forum - 10-22-2010 [eluser]prabhatshishodia[/eluser] if($show) { foreach($show as $row): ?> <p><strong> Name: </strong> <?php echo $row->name;?></p> <p><strong> resume:</strong><?php echo anchor( $row->filepath);?></> } i have done this code to get path :c:\xampp\htdocs\hr\resume but it show me http://localhost/hr/C:\xampp\htdocs\hr\resume. how i get only c:\xampp\htdocs\hr\resume then.hari.doc. where file filepath is the name in database where path is saved. reply soon ..please plase .how to show doc file - El Forum - 10-22-2010 [eluser]Narkboy[/eluser] Ok - that's clearer ![]() So - you have one resume per person. How do you store the resume file name for each user? If the files are under the web root you can literally just ahref to the file iteself: Code: <a href="/resume/jack.doc">Jacks Resume</a> HOWEVER! If you do keep these files under the web root, they are publically viewable to ANYONE. This also means that if you configure the upload poorly, I can upload a script to that directory and run any code I want. Bad idea! Better is to store them outside the web root. In this case, you'll need to use a controller to access them. If your controller is "download.php" and the function is "resume" then you can link to: Code: <a href="<?php echo site_url('download/resume'); ?>">Jacks Resume</a> The controller needs to know what file to get, and it's safer to use and id rather than the filename. Here is a full controller function which grabs a rota file for display: Code: function get_rota($rota_id='') { The function expects and integer id, uses that to get the file name from the database ($filename = $this->arc_model->get_rota_filename($rota_id) ![]() This means 1) you can't view any file you want, only those you know the id for, and 2) files are not parsed by PHP, so dangerous uploads (if they get through) are not dangerous. Make sense? /B reply soon ..please plase .how to show doc file - El Forum - 10-22-2010 [eluser]prabhatshishodia[/eluser] ok sir .but sir i have generated the list of user dynamically.eg 1 jack 2 hari 3 ram when i click to jack show detail . it should show name:jack, age:12,resume:C:\xamp\htdocs\resume\jack.doc in anchor tag when i click this tag on jack.doc. i have data batase table tbluserinfo where field is name, age ,filepath,file name i store file path using 'filename' => $file['file_name'], 'filepath' => $this->gallery_path, save properly in database.and i retrieve name age .how i get anchor{resume name or Path) to open reply soon ..please plase .how to show doc file - El Forum - 10-22-2010 [eluser]prabhatshishodia[/eluser] <p><strong> resume:</strong><?php echo anchor( $row->filename);?></> it produce->http://localhost/hr/abc.doc and i need only C://xampp/htdocs/resume/abc.doc reply soon ..please plase .how to show doc file - El Forum - 10-22-2010 [eluser]Narkboy[/eluser] [quote author="prabhatshishodia" date="1287754546"]<p><strong> resume:</strong><?php echo anchor( $row->filename);?></> it produce->http://localhost/hr/abc.doc and i need only C://xampp/htdocs/resume/abc.doc[/quote] You do _not_ want to link to the file directly on the drive. The web link is the way to go - the link you need in this case is: http://localhost/resume/abc/doc So ,your $row->filename needs to return "/resume/abc.doc" Why is it listing "/hr/abc.doc"? You need to change the insert routine so that it lists the foilder correctly. /B reply soon ..please plase .how to show doc file - El Forum - 10-22-2010 [eluser]prabhatshishodia[/eluser] thanks sir just tell me one thing .anchor()function produce site url also.php have any function which only create file location link . here i have store address in a variable like $naam= $row->filename; $pata= $row->filepath; // echo anchor($pata.$naam); it produce http://localhost/hr c:/xamp/htdocs/hr/resume/abc.doc i need only any function which can create link of my variable name reply soon ..please plase .how to show doc file - El Forum - 10-22-2010 [eluser]Narkboy[/eluser] The URL helper function site_url() produces a link based on your config settings: site_url is added at the begining - http://example.com/ index page is added - index.php then the params you specify: 'controller/example' to produce: http://example.com/index.php/controller/example You do not want to use site_url because you are NOT pointing to a CI handled resource. You're pointing direct to a file. You need: Code: <a href="<?php echo $pata.'/'.$naam; ?>">Link Text</a> Now - assuming that: $pata = "/hr/resume/" $naam = "abc.doc" You'll get an output like: Code: <a href="/hr/resume/abc.doc">Link Text</a> You should not try to create a link starting with a drive letter. Don't do it. It's a very very bad idea. Also, more work. /B |