2

Since I changed my drupal to my backup that it's giving me some errors, but overall it stills working, but today I was about to add a new content and when I try to upload new images it shows me this error

"The file could not be uploaded."

And in log messages I've this message errors:

Location: http://localhost/node/add/imovel?_wrapper_format=drupal_ajax&ajax_form=1&element_parents=field_image%2Fwidget

Message: The upload directory public://2017-02 for the file field field_image could not be created or is not accessible. A newly uploaded file could not be saved in this directory as a consequence, and the upload was cancelled.

In the same location this 2 other errors:

Recoverable fatal error: Argument 1 passed to Drupal\Core\Form\FormState::setError() must be of the type array, null given

Notice: Undefined index: value in Drupal\Core\Field\Plugin\Field\FieldWidget\NumberWidget->errorElement()

Now I can't upload images and that don't allow me to add new content. I already try to create a new field but that didn't work.

PS: I think the error has to do something about Image Crop because before this error happen a box to crop my image would appear after I upload and know I upload and no box to crop the image.. And when I press save and publish content the error pops

The specified file temporary://filekrGdEp could not be moved/copied because the destination directory is not properly configured. This may be caused by a problem with file or directory permissions.

4
  • your first log message might be a permission issue or your public folder found in sites/default/files was deleted. Kindly double check. Commented Feb 13, 2017 at 15:40
  • I have the folder in "/home/user/public_html/sites/default/files/2017-02"
    – racemi
    Commented Feb 13, 2017 at 15:54
  • I see... There is a missing field that is required to be filled in the manage form display of your content type that is set to disabled/hidden. Commented Feb 13, 2017 at 16:01
  • What does any of that have to do with the image problem?
    – racemi
    Commented Feb 13, 2017 at 16:10

4 Answers 4

2

This sounds very much like a permission issue. Please check the permissions of

/home/user/public_html/sites/default/files/2017-02

The directory must be writeable for Drupal. Set its permissions at least to 710. You might want to set them for testing purposes to 755 or even 777 to see if your error messages disappear.

3
  • I already put my folder 'files' with permissions 777 and everything inside it. Didn't work, I'm going for a fresh start..
    – racemi
    Commented Feb 14, 2017 at 10:57
  • Please check permissions of your temporary directory also.
    – upunkt
    Commented Feb 14, 2017 at 13:05
  • I also did that, I ask a buddy help and we were in that for over an hour and then he told me it was better to start over. Too many bugs, you fix one -> one more appears
    – racemi
    Commented Feb 14, 2017 at 13:15
0

Try setting private files path in settings.php to:

"../FOLDER_WITH_PRIVATE_FILES"

-1

I was having this same error.

I didn't have important files in the folder. So I just deleted. Try to upload the file again, and it works, it created the folder and upload the files correctly.

If you already have files in the folder, you may just rename it, try the upload, and if it succeeds and creates the folder anew, you just move the files from the old folder to the new one.

Makes sense?

-1

The fact that i had to change the file permission of settings.php to 755 or above first then after mentioning all the things change it back to 555 then everything worked fine and i would suggest keeping the private directory on the same level as web and vendor directories and mention file path as ../private in settings.php.

2
  • Welcome to Drupal Answers! You could also have the private directory in a different directory and use the absolute path to access it. It would not make any difference, as long as the system account used for the web server and PHP has write access permission to that directory. It isn't clear what the first part of the answer is trying to say; I guess that is one of the reasons for the down-vote. (The other one could be that the suggested place for the private is irrelevant for the permission issue.)
    – avpaderno
    Commented Aug 5, 2021 at 20:44
  • By putting the directory outside the web folder you make it more easy to manage and permissions dont get all messed up.I had to go through all the permissions in my cpanel instead of doing it in my sftp Commented Aug 6, 2021 at 7:09

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.