简体   繁体   English

从codeigniter中的路径获取文件名

[英]Get filename from paths in codeigniter

HI guys i am trying to get the image/video filename from path 我们试图从路径获取图像/视频文件名

Here i have paths in my php variable like this from database 这里我在我的php变量中有这样的路径来自数据库

E:/xampp/htdocs/pes/new/movie.mp4
E:/xampp/htdocs/pes/new/flowers.jpg

And i am trying to get new/movie.mp4 or new/flowers.jpg from above paths and display it in img tag or video tag 我试图从上面的路径获取新的/ movie.mp4或new / flowers.jpg并将其显示在img标签或视频标签中

 <img src="new/flowers.jpg" alt="Trulli" width="500" height="333">

or 要么

<video width="400" controls>
      <source src="new/movie.mp4" type="video/mp4">
      Your browser does not support HTML5 video.
 </video>

Can anyone help me how to do that 谁能帮助我如何做到这一点

Thanks in advance 提前致谢

Try with base_url() . 尝试使用base_url() Set your base_url in config.php for example www.xyz.com/ Update your code like this: 在config.php中设置base_url,例如www.xyz.com/。像这样更新你的代码:

<img src="<?php echo base_url() ?>new/flowers.jpg" alt="Trulli" width="500" height="333">

And video frame: 和视频帧:

<video width="400" controls>
   <source src="<?php echo base_url() ?>new/movie.mp4" type="video/mp4">
                        Your browser does not support HTML5 video.
</video>

Hope this will help you! 希望这个能对您有所帮助!

If all paths are relative to FCPATH , FCPATH = 'E:/xampp/htdocs/pes' , you can use: 如果所有路径都相对于FCPATHFCPATH = 'E:/xampp/htdocs/pes' ,您可以使用:

<img src="<?php echo base_url(str_replace(FCPATH, '', 'E:/xampp/htdocs/pes/new/flowers.jpg')) ?>" alt="Trulli" width="500" height="333">

or 要么

<video width="400" controls>
    <source src="<?php echo base_url(str_replace(FCPATH, '', 'E:/xampp/htdocs/pes/new/movie.mp4')) ?>" type="video/mp4">
    Your browser does not support HTML5 video.
</video>

Hope this will help you : 希望这个能对您有所帮助 :

Set your base_url in your config.php config.php设置base_url

$config['base_url']='http://localhost/pes/'

and ur image src should be like this : 和你的图像src应该是这样的:

<img src="<?=site_url('new/'.$image); ?>" alt="Trulli" width="500" height="333">

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM