将文件上传到Linux服务器的根文件夹以外的文件夹? [英] Upload files to the folder outside root folder in Linux server?

查看:131
本文介绍了将文件上传到Linux服务器的根文件夹以外的文件夹?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的项目中,我必须将一些视频文件上传到位于根文件夹之外的文件夹。我使用简单的php函数 move_uploaded_file 来上传文件。

  $ source = $ _FILES ['Filedata'] ['tmp_name']; 
$ targetFile ='/usr/local/WowzaMediaServer-3.1.1/content/video.mp4'
move_uploaded_file($ source,$ targetFile);

但是不行。我们可以通过 move_uploaded_file 来完成。如果没有,建议一个更好的选择做到这一点。



我已经看到了一些类似的问题,但没有什么帮助。所以任何帮助将不胜感激。

解决方案

更多可能这是一个简单的权限问题,很容易解决。 p>


  1. 找到apache使用的用户。要做到这一点打开你的httpd.conf文件,并寻找类似的东西:



    用户apache

    组apache


  2. 更改您要上传的文件夹的所有权。

    chown -R apache.apache / usr /本地/ WowzaMediaServer-3.1.1 / content /


  3. 更改文件夹的权限

    -R 775 /usr/local/WowzaMediaServer-3.1.1/content/


那应该是。 / p>

In my project, I have to upload some video files to a folder which lies outside the root folder. I am using simple php function move_uploaded_file to upload the file. I have tried with the code below.

$source  = $_FILES['Filedata']['tmp_name'];
$targetFile = '/usr/local/WowzaMediaServer-3.1.1/content/video.mp4'
move_uploaded_file($source,$targetFile);

But it is not working. Can we done it through move_uploaded_file. if not, suggest a better option to do this.

I have seen some similar question but nothing helps. So any help would be appreciated..

解决方案

More than likely this is a simple permissions issue and quite easy to solve.

  1. Find the user that apache uses. To do this open up your httpd.conf file and look for something like:

    User apache
    Group apache

  2. Change the ownership of the folder that you're trying to upload to.

    chown -R apache.apache /usr/local/WowzaMediaServer-3.1.1/content/

  3. Change the permissions of the folder

    chmod -R 775 /usr/local/WowzaMediaServer-3.1.1/content/

And that should be that.

这篇关于将文件上传到Linux服务器的根文件夹以外的文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆