I am running Drupal 8 and am using the exact code from the Form_Example_Tutorial_10 to upload a file. The only difference is I am uploading a document, not an image. The first problem I had was with the "file_move($file, 'public://') line, which was giving me an error because I was passing an array in the first argument. I was passing the result from the "$file = file_save_upload('file'), array..." procedure. My form field is defined as 'file', and I added "#multiple=FALSE" to ensure I was only uploading one file. The documentation for file_save_upload states that if only one file is uploaded it is supposed to return a single file entity, but it wasn't, it was returning an array. "file_move" needs a file entity, not an array. I added the $depth parameter to the file_save_upload and that forced it to return a single file entity, which got the "file_move" working. But the very next line "$form_state['storage']['file'] = $file;" is not working, nor is it giving me a specific error. The browser just displays "The website cannot display the page".
I'm sure the example tutorial works, but that means I must be missing a piece somewhere. Anyone have any idea what I'm missing?
Comments