views:

114

answers:

2

I'm writing a class that excepts 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 getting as far as creating a directory (which should happen in the constructor)

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

+2  A: 

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.

dclowd9901
I'll give this a try, I'm on localhost
ThinkingInBits
I tried unchecking readonly, but it kept reverting back when I'd reopen the folder properties.
ThinkingInBits
Try changing the properties in an admin account. If your account is already deemed a token "admin account" (which, on Windows, doesn't necessarily mean you have unlimited access), try the steps on this page: http://www.howtogeek.com/howto/windows-vista/enable-the-hidden-administrator-account-on-windows-vista/
dclowd9901
A: 

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());
     }
}
Marc B