0

I'm going through some doubts about how do i need to set up my environment to be able to use this function correctly.

What i do really need is something like this:

I'm developing a classified website for my city, where each user has its id. When an user posts an ad, i have to take all the files he uploaded and move them to a new (or not new) directory.

The name of this directory is the user ID.

Does the function 'move_uploaded_file' create the directory if it does not exist? If not, how could i do that?

Example:

//getUID() returns 5
//current directory: www/

move_uploaded_file('some_temp_file.ext','adimg/' . getUID() . '/new_file.ext');

Is it going to create the folder '5' and move the temporary file to it?

And how do i need to configure my folders (I'm testing it under Windows).

Thanks!

2
  • 1
    You can always programatically create the directory as long as your parent directory has the worldwide write access (777 in *nix, in Windows just tick those checkboxes to allow write access). Commented Oct 25, 2012 at 2:06
  • @AlvinWong Perfect. Now the thing is that i can't open the uploaded files, i don't know why i don't have permissions to do it. The files are uploaded, the folders is created but i can't open them.. Commented Oct 25, 2012 at 2:25

1 Answer 1

2

Use php mkdir() function. before using move_uploade_file() to create the directory(if you are creating the foler via php) where you want to put the files.

If you cant edit the folder persisson by checkboxes, you can set it via ftp client.

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.