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条)

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?