solspace / craft-freeform

Freeform for Craft: The most reliable form builder that's ready for wherever your project takes you.
https://docs.solspace.com/craft/freeform/v5/
Other
47 stars 60 forks source link

File upload field results in 500 (stream_copy_to_stream(): Argument #2 ($to) must be of type resource) #401

Closed charliestrafe closed 2 years ago

charliestrafe commented 2 years ago

Describe the bug or issue you're experiencing I cannot upload any files to my file upload field, it results in a 500 error in the console which means the file is not saved to the form & not uploaded to my user uploads directory. The following is what is returned in the network 500 error.

{"message":"stream_copy_to_stream(): Argument #2 ($to) must be of type resource, bool given","exception":"TypeError","file":"/Users/john/mysite/vendor/craftcms/cms/src/fs/Local.php","line":222,"trace":[{"file":"/Users/john/mysite/vendor/craftcms/cms/src/fs/Local.php","line":222,"function":"stream_copy_to_stream"},{"file":"/Users/john/mysite/vendor/craftcms/cms/src/elements/Asset.php","line":2651,"function":"writeFileFromStream","class":"craft\\fs\\Local","type":"->"},{"file":"/Users/john/mysite/vendor/craftcms/cms/src/elements/Asset.php","line":2382,"function":"_relocateFile","class":"craft\\elements\\Asset","type":"->"},{"file":"/Users/john/mysite/vendor/craftcms/cms/src/services/Elements.php","line":2695,"function":"afterSave","class":"craft\\elements\\Asset","type":"->"},{"file":"/Users/john/mysite/vendor/craftcms/cms/src/services/Elements.php","line":765,"function":"_saveElementInternal","class":"craft\\services\\Elements","type":"->"},{"file":"/Users/john/mysite/vendor/solspace/craft-freeform/packages/plugin/src/Services/FilesService.php","line":200,"function":"saveElement","class":"craft\\services\\Elements","type":"->"},{"file":"/Users/john/mysite/vendor/solspace/craft-freeform/packages/plugin/src/Controllers/FileUploadController.php","line":83,"function":"uploadDragAndDropFile","class":"Solspace\\Freeform\\Services\\FilesService","type":"->"},{"function":"actionPost","class":"Solspace\\Freeform\\Controllers\\FileUploadController","type":"->"},{"file":"/Users/john/mysite/vendor/yiisoft/yii2/base/InlineAction.php","line":57,"function":"call_user_func_array"},{"file":"/Users/john/mysite/vendor/yiisoft/yii2/base/Controller.php","line":178,"function":"runWithParams","class":"yii\\base\\InlineAction","type":"->"},{"file":"/Users/john/mysite/vendor/yiisoft/yii2/base/Module.php","line":552,"function":"runAction","class":"yii\\base\\Controller","type":"->"},{"file":"/Users/john/mysite/vendor/craftcms/cms/src/web/Application.php","line":301,"function":"runAction","class":"yii\\base\\Module","type":"->"},{"file":"/Users/john/mysite/vendor/yiisoft/yii2/web/Application.php","line":103,"function":"runAction","class":"craft\\web\\Application","type":"->"},{"file":"/Users/john/mysite/vendor/craftcms/cms/src/web/Application.php","line":286,"function":"handleRequest","class":"yii\\web\\Application","type":"->"},{"file":"/Users/john/mysite/vendor/yiisoft/yii2/base/Application.php","line":384,"function":"handleRequest","class":"craft\\web\\Application","type":"->"},{"file":"/Users/john/mysite/web/index.php","line":14,"function":"run","class":"yii\\base\\Application","type":"->"},{"file":"/Users/john/.composer/vendor/laravel/valet/server.php","line":234,"function":"require"}],"error":"stream_copy_to_stream(): Argument #2 ($to) must be of type resource, bool given"}

The following is my file upload field settings in Freeform Screenshot 2022-07-21 at 12 11 36

The following is the request URL when a file is uploaded Screenshot 2022-07-21 at 12 15 30

Steps to reproduce

  1. Add a form with a file upload field
  2. Attach a file and submit the form

Expected behavior The file should attach and be saved to the assets

Craft & Plugin Info (please complete the following information):

kjmartens commented 2 years ago

Hi @charliestrafe, just to confirm, you figured out what the issue was? 🙂