简体   繁体   中英

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. 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? Could you print out the output of following command:

ls -l ../users

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.

Also try to change error_reporting to ALL in your php.ini to see the error message.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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