I am programmatically importing images and saving them via file_save_data();
$fileContentsPath = 'http://mypathtofile.com';
$uri = 'public://myfolder/mysecondfolder/filename.jpg';
$image = @file_get_contentsfile_get_contents($fileContentsPath);
$file = file_save_data($image, $uri, FILE_EXISTS_REPLACE);
When I run this I get the following error: The specified file temporary://fileJ4LL4o could not be copied, because the destination directory is not properly configured. This may be caused by a problem with file or directory permissions. More information is available in the system log.
MyI am pretty sure my temporary directory is configured correctly and the files folder is assigned to the apache user.
If I go ininto the files directory and make the directories (myfolder/mysecondfolder) via command line and rerun it works correctly.
So the problem is that if the folders don't exist from the $uri path, it fails instead of creating the folders.