douyuai8994 2015-09-07 12:36
浏览 71
已采纳

试图用PHP重命名两个文件

I'm using Ubuntu 12.04, apache2 + nginx (ISPManager)

My server works with Wowza Media Server, and that server put my recorded .flv videos in {root-of-the-server}/movies

I recieve the name of video from $_GET['rfile'] of the action: $this->request->get('rfile').

The file is created in the folder successfully, I locate it in two ways:

file_get_contents('http://<ip, which sends to {root-of-the-server}>/movies/'.$this->request->get('rfile'));

or

`find /movies/ -name $rfile`;

To upload my rec videos from the Wowza folder to web-site, I'm trying to rename the file after the recording is stopped:

From
'{root-of-the-server}/movies/$this->request->get('rfile').flv'
To
'.$_SERVER['DOCUMENT_ROOT'].'/upload/resume/resume'.$item['id'].'.flv'

I use $_SERVER['DOCUMENT_ROOT'], because I need to move the recorded videos automatically, and on the several websites.

Note: I don't put the {root-of-the-server} in my actual script, that's just a placeholder for posting here.

I'm trying to rename this with PHP.
First try:
shell_exec('mv /movies/'.$this->request->get('rfile').''.$_SERVER['DOCUMENT_ROOT'].'/upload/resume/resume'.$item['id'].'.flv');
Second try:
mv /movies/$rfile /movies/ok-just-rename-it-plz.flv
Third try:
rename('http://95.183.8.96:81/'.$this->request->get('rfile'), 'http://95.183.8.96:81/'.$item['id'].'.flv');
Fourth try:
rename('/movies/'.$this->request->get('rfile'), '/upload/resume/resume'.$item['id'].'.flv');

However none of these attempts worked. How can I rename these two files with a http wrapper? Or how can I rename them in another way?

  • 写回答

2条回答 默认 最新

  • doumiang2297 2015-09-07 22:52
    关注

    My problem of these days was in open_basedir of ISPmanager (open_basedir is turned on by default). I went to /etc/apache2/apache2.conf and made these changes:

    <Directory /var/www/USER/data/www/WEBSITE> php_admin_value open_basedir "/movies:/var/www/USER/data:." </Directory>

    instead of

    <Directory /var/www/USER/data/www/WEBSITE> php_admin_value open_basedir "/var/www/USER/data:." </Directory>

    Anyway, thanks to Kevin Nagurski for answer :33

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥65 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?
  • ¥15 乘性高斯噪声在深度学习网络中的应用