1

I have a project where Red5 is recording videos. I need PHP to be able to access the videos and move them so they can be accessed by HTML.

How can I do this?

I found this post: Accessing files outside the document root with Apache

But it involves updating some file that was never specified. And I'm not sure it is a viable solution in this case anyway.

lee

Community
  • 1
  • 1
Lee Loftiss
  • 3,035
  • 7
  • 45
  • 73

1 Answers1

3

PHP by default can already access files outside the web root, unless restricted with an open_basedir directive (or safe mode, but hope you're not in that cage).

It's normally a good practice to insert within a VirtualHost configuration an open_basedir restriction. You can specify multiple directories separated by : on Linux and ; on windows.

php_admin_value open_basedir /var/www/s/stage:/usr/share/php:/your/dir

To access those files either use an absolute path or a path relative to the position of the PHP file called. (So you'll have to ../ to reach levels above).

Also be sure that directories in which you want to write to are assigned to the webserver user and have write permission.

stivlo
  • 83,644
  • 31
  • 142
  • 199
  • Would it be possible to send the command 'cp /a/b/file /g/h/file' ? – Lee Loftiss Nov 14 '11 at 10:32
  • 1
    use PHP [copy](http://php.net/manual/en/function.copy.php) though, although I am not sure if it's a good idea to copy media files on the fly... What are you trying to achieve? Copy when they pay? – stivlo Nov 14 '11 at 10:36
  • 1
    @LeeLoftiss - You are overcomplicating things in your mind. 1) The `cp` command was already two decades old when the web was invented. 2) PHP can copy files natively. – Álvaro González Nov 14 '11 at 10:37
  • stivlo - Red5 records video through Flash. However, it records to its own directory. I want to be able to move that FLV to a place that it can be accessed by a webpage. – Lee Loftiss Nov 14 '11 at 11:55
  • 1
    On Linux you can consider making a symbolic link and activate the follow symbolic link option in Apache. – stivlo Nov 14 '11 at 11:58