简体   繁体   English

上载文件在Linux中不起作用

[英]uploading file doesn't work in linux

So I have code for uploading image to server that actually work when I tested it on the windows system, but as soon as I put it on Linux, it is doesn't work. 因此,我有将图像上传到服务器的代码,当我在Windows系统上对其进行测试时,该代码实际上可以工作,但是一旦将其放在Linux上,它就无法工作。 So problem is that it doesn't give me any mistake, in the end it put the link on data base, but doesn't put the image in the folder where it spouse to be. 因此,问题在于它不会给我任何错误,最终它会将链接放在数据库中,但没有将图像放在其配偶所在的文件夹中。 So the problem is only in uploading image in server. 因此,问题仅在于在服务器中上传图像。 So here is the code where the path and image download. 因此,这里是下载路径和图像的代码。

$path = "../users/".$IDN."/";
        if(preg_match('/[.](JPG)|(jpg)|(jpeg)|(JPEG)|(gif)|(GIF)|(png)|(PNG)$/',$_FILES['imgupload']['name']))
        {
            $filename = $_FILES['imgupload']['name'];

                $source = $_FILES['imgupload']['tmp_name'];
                $target = $path.$filename;
                move_uploaded_file($source, $target);
// and other funny actions

What is the owner/group of that ../users/$IDN? 该../users/$IDN的所有者/组是什么? Could you print out the output of following command: 您可以打印出以下命令的输出:

ls -l ../users ls -l ../用户

Also what is your web service? 另外,您的网络服务是什么? Is it apache? 是阿帕奇吗? What username your web server is running with? 您的网络服务器使用什么用户名?

If your web service user does not have permission to write in target directory, then you can't really write unless you change permission. 如果您的Web服务用户没有在目标目录中写入的权限,那么除非更改权限,否则您将无法真正写入。

Also try to change error_reporting to ALL in your php.ini to see the error message. 也可以尝试在php.ini中将error_reporting更改为ALL,以查看错误消息。

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

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