Question

Environment info:
*Windows Vista
*PHP 5.2.9-2

I'm working on a project. Let's say it's name simply "project". My php files meant for user-interaction will be found at

project/file.php

Now, I have a database behind this and some maps, which contain classes and configuration files in general. There is also a map for the users, in which I store images they might upload. For instance:

project/files/Users/0/profilePic.jpg

The number corresponds with the user_id in the database.

My register.php file contains this line of code:

mkdir('/files/Users/'.$id)

The $id variable is the biggest id number in the database, plus 1.

But it won't work. I checked the folders, I have both read and write permissions(I am admin on my machine).

What am I doing wrong?

Note: the right to tell me there's a better way to organize this reserved to those who can give me a helpful answer. :P

Was it helpful?

Solution

What about this?

mkdir('c:/files/Users/'.$id)

OTHER TIPS

Couple of possibilities:

  1. Lose the first / since that gives an absolute path and you're looking to make a relative path -- so mkdir('files/Users/'.$id)
  2. Does files/Users already exist (i.e., is there already user 0, user 1, etc.)? If not, you'll need to make them first or do mkdir('files/Users/'.$id, 077, true) to recursively create the directories.

In windows, a path does not start with '/' but with a drive letter. Just remove the first slash (so '/files/users/' becomes 'files/users/').

Further, what Mark said.

PHP states that it makes the best attempt at converting the / between systems. by doing:

mkdir('/files/users');

Confused PHP into thinking it was on a *NIX system. By setting the root to c:, it was now able to properly parse the parameter and deduce that it was a windows system

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top