0

I am trying to upload a file using PHP, using an html form. in the form it asks for an album name, then in the PHP file it references, I need it to create a directory from that value of the form.

However, when I try this:

if (!file_exists('data/$album_name')) {
    mkdir('data/$album_name', 0777,true);
}

But it just creates the directory, in the 'data' folder, of name '$album_name' instead of the value of $album_name.

I'm new to php, please help!

1 Answer 1

2

You're using single quotes which prevents your variables from being interpolated. Use double quotes instead:

mkdir("data/$album_name", 0777,true);
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.