开发者

PHP Image Upload object won't create directory on windows

I'm writing a class that accepts a product_id and a $_FILES array as it's constructor. The class saves these variables and uses them to create a new directory named by product_id and attempts to copy the temp file to my specified directory.

For some reason my class isn't even ge开发者_开发百科tting as far as creating a directory (which should happen in the constructor)

Here's a link to my code: http://pastie.org/955454


This could be a permissions issue. You say it's a Windows based server? Do you own this machine? Are you using a dedicated server? Are you using a shared server?

The answer to this question really depends on the information given by those. If you own the machine, you can simply go to the directory on your hard disk that you want writeable and open up its permissions to be written to. If it's dedicated, there's probably a reasonably easy means of accessing the file structure and changing its permission settings there. If it's shared, same thing.


It appears that you're using an absolute path in this $this->directory in the constructor, in other words, it'll be treated as C:\images\upload (or whatever drive you're running the site from). If you mean this to be a URI type path, then you'll need to add your webroot to the path:

$this->directory = $_SERVER['DOCUMENT_ROOT'] . '/images/upload/' . $this->prod_id

You may also want to check what mkdir()'s returning. It's FALSE on failure, after which you could check error_get_last() (PHP >= 5.2) to see exactly why it's failing.

} else {
     $ret = mkdir($this->directory, 0755, true);
     if ($ret === FALSE) {
        die("mkdir() failed with: " . error_get_last());
     }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜