1

I have got this,

$destinationPath = public_path(). '/img/'. $username;

which I thought would create the directory alright, but it came up with a

Symfony \ Component \ HttpFoundation \ File \ Exception \ FileException

Unable to create the "/img/alvarito" directory

Any idea what is wrong? seems to me that it is trying to create also the /img/, which already exists, what I naturally want is that inside that 'img' directory creates me subdirectories for each user as they upload their files.

thanks a lot

A

0

1 Answer 1

1

You may try this:

$destinationPath = public_path(). '/img/'. $username;

if(!file_exists($destinationPath)) File::makeDirectory($destinationPath);

This will create the directory if it doesn't exist.

7
  • Hello. Thank you for answering, I got this reply: mkdir(): No such file or directory Jun 19, 2014 at 9:17
  • Could it be a matter of permissions? I am using a dedicated server, how do I check that permissions thing? Jun 19, 2014 at 9:28
  • It could be permission related problem, Check this answer.
    – The Alpha
    Jun 19, 2014 at 9:33
  • I have directly looked through Filezilla, directory img has 0755, does that mean, 7 = can read anything, 5 can read and execute but not write? is that the reason? But that is a public directory I would not want non-registered people to write in a directory. However, I was told, images are saved in a Public directory. Jun 19, 2014 at 9:46
  • Yes, 7 = 4+2+1 (read/write/execute) 6 = 4+2 (read/write) 5 = 4+1 (read/execute) 4 = 4 (read) 3 = 2+1 (write/execute) 2 = 2 (write) 1 = 1 (execute)
    – The Alpha
    Jun 19, 2014 at 9:52

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.